Skip to content

Commit b865993

Browse files
committed
Update based on function namespace packages
1 parent 5543eb3 commit b865993

7 files changed

Lines changed: 10 additions & 22 deletions

File tree

lib/node_modules/@stdlib/assert/is-arrow-function/lib/main.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
// MODULES //
2222

2323
var isFunction = require( '@stdlib/assert/is-function' );
24+
var function2string = require( '@stdlib/function/to-string' );
2425

2526

2627
// VARIABLES //
2728

2829
var RE_ARROW_FUNCTION = /^(?:\([^)]*\) *|[^=]*)=>/;
2930

30-
// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating an arrow function:
31-
var fcn2str = Function.prototype.toString;
32-
3331

3432
// MAIN //
3533

@@ -57,7 +55,7 @@ function isArrowFunction( value ) {
5755
if ( !isFunction( value ) ) {
5856
return false;
5957
}
60-
str = fcn2str.call( value );
58+
str = function2string( value );
6159
return RE_ARROW_FUNCTION.test( str );
6260
}
6361

lib/node_modules/@stdlib/assert/is-browser/lib/global_scope.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
/* eslint-disable no-new-func */
20-
2119
'use strict';
2220

2321
// VARIABLES //
@@ -40,7 +38,7 @@ function globalScope() {
4038
fcn += '} catch ( err ) {';
4139
fcn += 'return false;';
4240
fcn += '}';
43-
return (new Function( fcn ))();
41+
return (new Function( fcn ))(); // eslint-disable-line stdlib/require-globals, no-new-func
4442
}
4543

4644

lib/node_modules/@stdlib/assert/is-class/lib/main.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
// MODULES //
2222

2323
var isFunction = require( '@stdlib/assert/is-function' );
24+
var function2string = require( '@stdlib/function/to-string' );
2425

2526

2627
// VARIABLES //
2728

2829
var RE_CLASS = /^\s*class\s/;
2930

30-
// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a class:
31-
var fcn2str = Function.prototype.toString;
32-
3331

3432
// MAIN //
3533

@@ -56,7 +54,7 @@ function isClass( value ) {
5654
if ( !isFunction( value ) ) {
5755
return false;
5856
}
59-
str = fcn2str.call( value );
57+
str = function2string( value );
6058
return RE_CLASS.test( str );
6159
}
6260

lib/node_modules/@stdlib/assert/is-native-function/lib/main.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@
2222

2323
var isFunction = require( '@stdlib/assert/is-function' );
2424
var reNativeFunction = require( '@stdlib/regexp/native-function' );
25-
26-
27-
// VARIABLES //
28-
29-
// Using `Function#toString` bypasses a value's own `toString` method to provide an extra, but not security proof, precaution to prevent a provided function from impersonating a native function:
30-
var fcn2str = Function.prototype.toString;
25+
var function2string = require( '@stdlib/function/to-string' );
3126

3227

3328
// MAIN //
@@ -52,7 +47,7 @@ var fcn2str = Function.prototype.toString;
5247
function isNativeFunction( value ) {
5348
return (
5449
isFunction( value ) &&
55-
reNativeFunction.REGEXP.test( fcn2str.call( value ) )
50+
reNativeFunction.REGEXP.test( function2string( value ) )
5651
);
5752
}
5853

lib/node_modules/@stdlib/assert/is-node/lib/global_scope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function globalScope() {
3838
fcn += '} catch ( err ) {';
3939
fcn += 'return false;';
4040
fcn += '}';
41-
return (new Function( fcn ))(); // eslint-disable-line no-new-func
41+
return (new Function( fcn ))(); // eslint-disable-line no-new-func, stdlib/require-globals
4242
}
4343

4444

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
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' );
2627
var isPlainObject = require( './../lib' );
2728

2829

lib/node_modules/@stdlib/assert/is-web-worker/lib/global_scope.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
/* eslint-disable no-new-func */
20-
2119
'use strict';
2220

2321
// VARIABLES //
@@ -40,7 +38,7 @@ function globalScope() {
4038
fcn += '} catch ( err ) {';
4139
fcn += 'return false;';
4240
fcn += '}';
43-
return (new Function( fcn ))();
41+
return (new Function( fcn ))(); // eslint-disable-line stdlib/require-globals, no-new-func
4442
}
4543

4644

0 commit comments

Comments
 (0)