Skip to content

Commit 67d4932

Browse files
committed
Rename variable
This stems from investigating https://github.com/stdlib-js/math-base-tools-evalpoly/actions/runs/3062614392/jobs/4943787043. In short, Istanbul stores coverage data on the global `this` context. To access the global `this` context, Istanbul used the Function constructor: (Function(){'return this;'}()). Accordingly, when a module imports `@stdlib/function/ctor` and assigns to `Function`, this overwrites the global variable. Due to variable hoisting, the `Function` declaration was been hoisted to the top of the instrumented file's scope. It's initial value being undefined, as assignment took place later in the instrumented code. However, Istanbul's attempt to access the global `this` happens as the first line; hence, the issue. Istanbul was attempting to invoke the built-in `Function` constructor, but was unable to do so due to us redeclaring it via an import. This commit simply changes the variable to avoid this global reassignment.
1 parent 984a378 commit 67d4932

File tree

10 files changed

+23
-21
lines changed

10 files changed

+23
-21
lines changed

lib/node_modules/@stdlib/assert/is-plain-object/test/test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
var tape = require( 'tape' );
2424
var proxyquire = require( 'proxyquire' );
2525
var defineProperty = require( '@stdlib/utils/define-property' );
26-
var Function = require( '@stdlib/function/ctor' );
26+
var Fcn = require( '@stdlib/function/ctor' );
27+
var Object = require( '@stdlib/object/ctor' );
2728
var isPlainObject = require( './../lib' );
2829

2930

@@ -160,7 +161,7 @@ tape( 'the function returns `false` if provided a value whose prototype does not
160161
this.c = 'd';
161162
return this;
162163
}
163-
Foo.prototype = Object.create( Function.prototype );
164+
Foo.prototype = Object.create( Fcn.prototype );
164165
Foo.prototype.constructor = Foo;
165166
Foo.prototype.isPrototypeOf = function beep() {};
166167
Foo.prototype.boop = 'boop';

lib/node_modules/@stdlib/math/base/tools/evalpoly/lib/factory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var Function = require( '@stdlib/function/ctor' );
23+
var Fcn = require( '@stdlib/function/ctor' );
2424
var evalpoly = require( './evalpoly.js' );
2525

2626

@@ -100,7 +100,7 @@ function factory( c ) {
100100
f += '//# sourceURL=evalpoly.factory.js';
101101

102102
// Create the function in the global scope:
103-
return ( new Function( f ) )();
103+
return ( new Fcn( f ) )();
104104

105105
/*
106106
* function evalpoly( x ) {

lib/node_modules/@stdlib/math/base/tools/evalrational/lib/factory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var Function = require( '@stdlib/function/ctor' );
23+
var Fcn = require( '@stdlib/function/ctor' );
2424
var evalrational = require( './main.js' );
2525

2626

@@ -173,7 +173,7 @@ function factory( P, Q ) {
173173
f += '//# sourceURL=evalrational.factory.js';
174174

175175
// Create the function in the global scope:
176-
return ( new Function( f ) )();
176+
return ( new Fcn( f ) )();
177177

178178
/*
179179
* function evalrational( x ) {

lib/node_modules/@stdlib/regexp/native-function/lib/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var Function = require( '@stdlib/function/ctor' );
23+
var Fcn = require( '@stdlib/function/ctor' );
2424
var function2string = require( '@stdlib/function/to-string' );
2525

2626

@@ -40,7 +40,7 @@ function reNativeFunction() {
4040
var str = '';
4141

4242
// Use a native function as a template:
43-
str += function2string( Function );
43+
str += function2string( Fcn );
4444

4545
// Escape special RegExp characters:
4646
str = str.replace( /([.*+?^=!:$(){}|[\]\/\\])/g, '\\$1' ); // eslint-disable-line no-useless-escape

lib/node_modules/@stdlib/utils/decorate-after/lib/factory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert/is-function' );
2424
var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive;
2525
var reNativeFunction = require( '@stdlib/regexp/native-function' ).REGEXP;
2626
var function2string = require( '@stdlib/function/to-string' );
27-
var Function = require( '@stdlib/function/ctor' );
27+
var Fcn = require( '@stdlib/function/ctor' );
2828
var format = require( '@stdlib/string/format' );
2929

3030

@@ -211,7 +211,7 @@ function decorateAfter( fcn, arity, after, thisArg ) {
211211
f += '//# sourceURL=decorateAfter.factory.js';
212212

213213
// Create the function the global scope:
214-
return (new Function( f ))()( fcn, after, thisArg );
214+
return (new Fcn( f ))()( fcn, after, thisArg );
215215
}
216216

217217

lib/node_modules/@stdlib/utils/flatten-array/lib/gen_fcn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var Function = require( '@stdlib/function/ctor' );
23+
var Fcn = require( '@stdlib/function/ctor' );
2424

2525

2626
// MAIN //
@@ -79,7 +79,7 @@ function genFcn( dims ) {
7979
f += '//# sourceURL=flatten_array.gen_fcn.js';
8080

8181
// Create the function in the global scope:
82-
return ( new Function( f ) )();
82+
return ( new Fcn( f ) )();
8383

8484
/*
8585
* e.g.,

lib/node_modules/@stdlib/utils/function-name/test/test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ var proxyquire = require( 'proxyquire' );
2525
var Int8Array = require( '@stdlib/array/int8' );
2626
var Buffer = require( '@stdlib/buffer/ctor' );
2727
var Number = require( '@stdlib/number/ctor' );
28-
var Function = require( '@stdlib/function/ctor' );
28+
var Boolean = require( '@stdlib/boolean/ctor' );
29+
var Fcn = require( '@stdlib/function/ctor' );
2930
var functionName = require( './../lib' );
3031

3132

@@ -76,7 +77,7 @@ tape( 'the function returns a function\'s name', function test( t ) {
7677
t.equal( functionName( Int8Array ), 'Int8Array', 'returns Int8Array' );
7778
t.equal( functionName( Boolean ), 'Boolean', 'returns Boolean' );
7879
t.equal( functionName( String ), 'String', 'returns String' );
79-
t.equal( functionName( Function ), 'Function', 'returns Function' );
80+
t.equal( functionName( Fcn ), 'Function', 'returns Function' );
8081
t.end();
8182
});
8283

@@ -96,7 +97,7 @@ tape( 'if provided an anonymous function, the function returns an empty string o
9697
name = functionName( function () {} ); // eslint-disable-line func-names
9798
t.equal( check( name ), true, 'returns an empty string (or "anonymous")' );
9899

99-
name = functionName( new Function('a', 'b', 'return') );
100+
name = functionName( new Fcn('a', 'b', 'return') );
100101
t.equal( check( name ), true, 'returns an empty string (or "anonymous")' );
101102

102103
t.end();

lib/node_modules/@stdlib/utils/get-prototype-of/test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var tape = require( 'tape' );
2424
var Number = require( '@stdlib/number/ctor' );
2525
var Boolean = require( '@stdlib/boolean/ctor' );
26-
var Function = require( '@stdlib/function/ctor' );
26+
var Fcn = require( '@stdlib/function/ctor' );
2727
var Object = require( '@stdlib/object/ctor' );
2828
var getPrototypeOf = require( './../lib' );
2929

@@ -78,7 +78,7 @@ tape( 'the function returns the prototype of a provided value', function test( t
7878
Boolean.prototype,
7979
Array.prototype,
8080
Object.prototype,
81-
Function.prototype,
81+
Fcn.prototype,
8282
Date.prototype,
8383
RegExp.prototype,
8484
RegExp.prototype

lib/node_modules/@stdlib/utils/get-prototype-of/test/test.native.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var tape = require( 'tape' );
2424
var Number = require( '@stdlib/number/ctor' );
2525
var Boolean = require( '@stdlib/boolean/ctor' );
26-
var Function = require( '@stdlib/function/ctor' );
26+
var Fcn = require( '@stdlib/function/ctor' );
2727
var Object = require( '@stdlib/object/ctor' );
2828
var getPrototypeOf = require( './../lib/native.js' );
2929

@@ -60,7 +60,7 @@ tape( 'the function returns the prototype of a provided value', function test( t
6060
Boolean.prototype,
6161
Array.prototype,
6262
Object.prototype,
63-
Function.prototype,
63+
Fcn.prototype,
6464
Date.prototype,
6565
RegExp.prototype,
6666
RegExp.prototype

lib/node_modules/@stdlib/utils/get-prototype-of/test/test.polyfill.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var proxyquire = require( 'proxyquire' );
2525
var Number = require( '@stdlib/number/ctor' );
2626
var Boolean = require( '@stdlib/boolean/ctor' );
2727
var Object = require( '@stdlib/object/ctor' );
28-
var Function = require( '@stdlib/function/ctor' );
28+
var Fcn = require( '@stdlib/function/ctor' );
2929
var getPrototypeOf = require( './../lib/polyfill.js' );
3030

3131

@@ -61,7 +61,7 @@ tape( 'the function returns the prototype of a provided value', function test( t
6161
Boolean.prototype,
6262
Array.prototype,
6363
Object.prototype,
64-
Function.prototype,
64+
Fcn.prototype,
6565
Date.prototype,
6666
RegExp.prototype,
6767
RegExp.prototype

0 commit comments

Comments
 (0)