Skip to content

Commit 1002297

Browse files
committed
Avoid immediately invoked requires
1 parent 1d12838 commit 1002297

8 files changed

Lines changed: 58 additions & 51 deletions

File tree

lib/node_modules/@stdlib/utils/constructor-name/examples/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
'use strict';
2020

21-
var hasMapSupport = require( '@stdlib/assert/has-map-support' )();
22-
var hasWeakMapSupport = require( '@stdlib/assert/has-weakmap-support' )();
23-
var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' )();
24-
var hasSetSupport = require( '@stdlib/assert/has-set-support' )();
25-
var hasWeakSetSupport = require( '@stdlib/assert/has-weakset-support' )();
21+
var hasMapSupport = require( '@stdlib/assert/has-map-support' );
22+
var hasWeakMapSupport = require( '@stdlib/assert/has-weakmap-support' );
23+
var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' );
24+
var hasSetSupport = require( '@stdlib/assert/has-set-support' );
25+
var hasWeakSetSupport = require( '@stdlib/assert/has-weakset-support' );
2626
var Float32Array = require( '@stdlib/array/float32' );
2727
var Float64Array = require( '@stdlib/array/float64' );
2828
var Int8Array = require( '@stdlib/array/int8' );
@@ -76,23 +76,23 @@ console.log( constructorName( /./ ) );
7676
console.log( constructorName( new Date() ) );
7777
// => 'Date'
7878

79-
if ( hasMapSupport ) {
79+
if ( hasMapSupport() ) {
8080
console.log( constructorName( new Map() ) );
8181
// => 'Map'
8282
}
83-
if ( hasWeakMapSupport ) {
83+
if ( hasWeakMapSupport() ) {
8484
console.log( constructorName( new WeakMap() ) );
8585
// => 'WeakMap'
8686
}
87-
if ( hasSetSupport ) {
87+
if ( hasSetSupport() ) {
8888
console.log( constructorName( new Set() ) );
8989
// => 'Set'
9090
}
91-
if ( hasWeakSetSupport ) {
91+
if ( hasWeakSetSupport() ) {
9292
console.log( constructorName( new WeakSet() ) );
9393
// => 'WeakSet'
9494
}
95-
if ( hasSymbolSupport ) {
95+
if ( hasSymbolSupport() ) {
9696
console.log( constructorName( Symbol( 'beep' ) ) );
9797
// => 'Symbol'
9898
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424

2525
var tape = require( 'tape' );
2626
var proxyquire = require( 'proxyquire' );
27-
var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' )();
28-
var hasMapSupport = require( '@stdlib/assert/has-map-support' )();
29-
var hasWeakMapSupport = require( '@stdlib/assert/has-weakmap-support' )();
30-
var hasSetSupport = require( '@stdlib/assert/has-set-support' )();
31-
var hasWeakSetSupport = require( '@stdlib/assert/has-weakset-support' )();
27+
var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' );
28+
var hasMapSupport = require( '@stdlib/assert/has-map-support' );
29+
var hasWeakMapSupport = require( '@stdlib/assert/has-weakmap-support' );
30+
var hasSetSupport = require( '@stdlib/assert/has-set-support' );
31+
var hasWeakSetSupport = require( '@stdlib/assert/has-weakset-support' );
3232
var Float32Array = require( '@stdlib/array/float32' );
3333
var Float64Array = require( '@stdlib/array/float64' );
3434
var Int8Array = require( '@stdlib/array/int8' );
@@ -177,7 +177,7 @@ tape( 'the function supports environments lacking `Function.name` support', func
177177

178178
tape( 'the function supports Map objects (ES2015)', function test( t ) {
179179
var v;
180-
if ( hasMapSupport ) {
180+
if ( hasMapSupport() ) {
181181
v = constructorName( new Map() );
182182
t.equal( v, 'Map', 'returns Map' );
183183
}
@@ -186,7 +186,7 @@ tape( 'the function supports Map objects (ES2015)', function test( t ) {
186186

187187
tape( 'the function supports WeakMap objects (ES2015)', function test( t ) {
188188
var v;
189-
if ( hasWeakMapSupport ) {
189+
if ( hasWeakMapSupport() ) {
190190
v = constructorName( new WeakMap() );
191191
t.equal( v, 'WeakMap', 'returns WeakMap' );
192192
}
@@ -195,7 +195,7 @@ tape( 'the function supports WeakMap objects (ES2015)', function test( t ) {
195195

196196
tape( 'the function supports Set objects (ES2015)', function test( t ) {
197197
var v;
198-
if ( hasSetSupport ) {
198+
if ( hasSetSupport() ) {
199199
v = constructorName( new Set() );
200200
t.equal( v, 'Set', 'returns Set' );
201201
}
@@ -204,7 +204,7 @@ tape( 'the function supports Set objects (ES2015)', function test( t ) {
204204

205205
tape( 'the function supports WeakSet objects (ES2015)', function test( t ) {
206206
var v;
207-
if ( hasWeakSetSupport ) {
207+
if ( hasWeakSetSupport() ) {
208208
v = constructorName( new WeakSet() );
209209
t.equal( v, 'WeakSet', 'returns WeakSet' );
210210
}
@@ -213,7 +213,7 @@ tape( 'the function supports WeakSet objects (ES2015)', function test( t ) {
213213

214214
tape( 'the function supports Symbol objects (ES2015)', function test( t ) {
215215
var v;
216-
if ( hasSymbolSupport ) {
216+
if ( hasSymbolSupport() ) {
217217
v = constructorName( Symbol( 'foo' ) );
218218
t.equal( v, 'Symbol', 'returns Symbol' );
219219
}

lib/node_modules/@stdlib/utils/copy/test/test.copy_error.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var hasClass = require( '@stdlib/assert/has-class-support' )();
24+
var hasClassSupport = require( '@stdlib/assert/has-class-support' );
2525
var copy = require( './../lib' );
2626

2727

@@ -33,6 +33,7 @@ var createClass = require( './fixtures/customerror.subclass.js' );
3333

3434
// VARIABLES //
3535

36+
var hasClass = hasClassSupport();
3637
var opts = {
3738
'skip': !hasClass
3839
};

lib/node_modules/@stdlib/utils/eval/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ var v = evil( '5*4*3*2*1' );
6262
```javascript
6363
var evil = require( '@stdlib/utils/eval' );
6464

65+
var ctors;
66+
var fcn;
67+
var i;
68+
6569
function compile( ctor ) {
6670
var name;
6771
var str;
@@ -82,10 +86,6 @@ function compile( ctor ) {
8286
return str;
8387
}
8488

85-
var ctors;
86-
var fcn;
87-
var i;
88-
8989
ctors = [
9090
'Int8Array',
9191
'Uint8Array',

lib/node_modules/@stdlib/utils/eval/examples/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818

1919
'use strict';
2020

21-
var hasClass = require( '@stdlib/assert/has-class-support' )();
21+
var hasClassSupport = require( '@stdlib/assert/has-class-support' );
2222
var evil = require( './../lib' );
2323

24+
var hasClass = hasClassSupport();
25+
var ctors;
26+
var fcn;
27+
var i;
28+
2429
function compile( ctor ) {
2530
var name;
2631
var str;
@@ -54,10 +59,6 @@ function compile( ctor ) {
5459
return str;
5560
}
5661

57-
var ctors;
58-
var fcn;
59-
var i;
60-
6162
ctors = [
6263
'Int8Array',
6364
'Uint8Array',

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@
2121
// MODULES //
2222

2323
var isFunction = require( '@stdlib/assert/is-function' );
24-
var isFunctionNameSupported = require( '@stdlib/assert/has-function-name-support' )();
24+
var hasFunctionNameSupport = require( '@stdlib/assert/has-function-name-support' );
2525
var RE = require( '@stdlib/regexp/function-name' );
2626

2727

28+
// VARIABLES //
29+
30+
var isFunctionNameSupported = hasFunctionNameSupport();
31+
32+
2833
// MAIN //
2934

3035
/**

lib/node_modules/@stdlib/utils/native-class/examples/index.js

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

2121
'use strict';
2222

23-
var hasMapSupport = require( '@stdlib/assert/has-map-support' )();
24-
var hasWeakMapSupport = require( '@stdlib/assert/has-weakmap-support' )();
25-
var hasSetSupport = require( '@stdlib/assert/has-set-support' )();
26-
var hasWeakSetSupport = require( '@stdlib/assert/has-weakset-support' )();
27-
var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' )();
23+
var hasMapSupport = require( '@stdlib/assert/has-map-support' );
24+
var hasWeakMapSupport = require( '@stdlib/assert/has-weakmap-support' );
25+
var hasSetSupport = require( '@stdlib/assert/has-set-support' );
26+
var hasWeakSetSupport = require( '@stdlib/assert/has-weakset-support' );
27+
var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' );
2828
var Float32Array = require( '@stdlib/array/float32' );
2929
var Float64Array = require( '@stdlib/array/float64' );
3030
var Int8Array = require( '@stdlib/array/int8' );
@@ -73,23 +73,23 @@ console.log( nativeClass( /./ ) );
7373
console.log( nativeClass( new Date() ) );
7474
// => '[object Date]'
7575

76-
if ( hasMapSupport ) {
76+
if ( hasMapSupport() ) {
7777
console.log( nativeClass( new Map() ) );
7878
// => '[object Map]'
7979
}
80-
if ( hasWeakMapSupport ) {
80+
if ( hasWeakMapSupport() ) {
8181
console.log( nativeClass( new WeakMap() ) );
8282
// => '[object WeakMap]'
8383
}
84-
if ( hasSetSupport ) {
84+
if ( hasSetSupport() ) {
8585
console.log( nativeClass( new Set() ) );
8686
// => '[object Set]'
8787
}
88-
if ( hasWeakSetSupport ) {
88+
if ( hasWeakSetSupport() ) {
8989
console.log( nativeClass( new WeakSet() ) );
9090
// => '[object WeakSet]'
9191
}
92-
if ( hasSymbolSupport ) {
92+
if ( hasSymbolSupport() ) {
9393
console.log( nativeClass( Symbol( 'beep' ) ) );
9494
// => '[object Symbol]'
9595
}

lib/node_modules/@stdlib/utils/native-class/test/test.native_class.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
// MODULES //
2424

2525
var tape = require( 'tape' );
26-
var hasMapSupport = require( '@stdlib/assert/has-map-support' )();
27-
var hasWeakMapSupport = require( '@stdlib/assert/has-weakmap-support' )();
28-
var hasSetSupport = require( '@stdlib/assert/has-set-support' )();
29-
var hasWeakSetSupport = require( '@stdlib/assert/has-weakset-support' )();
30-
var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' )();
26+
var hasMapSupport = require( '@stdlib/assert/has-map-support' );
27+
var hasWeakMapSupport = require( '@stdlib/assert/has-weakmap-support' );
28+
var hasSetSupport = require( '@stdlib/assert/has-set-support' );
29+
var hasWeakSetSupport = require( '@stdlib/assert/has-weakset-support' );
30+
var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' );
3131
var Float32Array = require( '@stdlib/array/float32' );
3232
var Float64Array = require( '@stdlib/array/float64' );
3333
var Int8Array = require( '@stdlib/array/int8' );
@@ -141,7 +141,7 @@ tape( 'the function returns a string indicating the specification defined classi
141141

142142
tape( 'the function supports Map objects (ES2015+)', function test( t ) {
143143
var v;
144-
if ( hasMapSupport ) {
144+
if ( hasMapSupport() ) {
145145
v = nativeClass( new Map() );
146146
t.strictEqual( v, '[object Map]', 'returns [object Map]' );
147147
}
@@ -150,7 +150,7 @@ tape( 'the function supports Map objects (ES2015+)', function test( t ) {
150150

151151
tape( 'the function supports WeakMap objects (ES2015+)', function test( t ) {
152152
var v;
153-
if ( hasWeakMapSupport ) {
153+
if ( hasWeakMapSupport() ) {
154154
v = nativeClass( new WeakMap() );
155155
t.strictEqual( v, '[object WeakMap]', 'returns [object WeakMap]' );
156156
}
@@ -159,7 +159,7 @@ tape( 'the function supports WeakMap objects (ES2015+)', function test( t ) {
159159

160160
tape( 'the function supports Set objects (ES2015+)', function test( t ) {
161161
var v;
162-
if ( hasSetSupport ) {
162+
if ( hasSetSupport() ) {
163163
v = nativeClass( new Set() );
164164
t.strictEqual( v, '[object Set]', 'returns [object Set]' );
165165
}
@@ -168,7 +168,7 @@ tape( 'the function supports Set objects (ES2015+)', function test( t ) {
168168

169169
tape( 'the function supports WeakSet objects (ES2015+)', function test( t ) {
170170
var v;
171-
if ( hasWeakSetSupport ) {
171+
if ( hasWeakSetSupport() ) {
172172
v = nativeClass( new WeakSet() );
173173
t.strictEqual( v, '[object WeakSet]', 'returns [object WeakSet]' );
174174
}
@@ -177,7 +177,7 @@ tape( 'the function supports WeakSet objects (ES2015+)', function test( t ) {
177177

178178
tape( 'the function supports Symbol objects (ES2015+)', function test( t ) {
179179
var v;
180-
if ( hasSymbolSupport ) {
180+
if ( hasSymbolSupport() ) {
181181
v = nativeClass( Symbol( 'beep' ) );
182182
t.strictEqual( v, '[object Symbol]', 'returns [object Symbol]' );
183183
}

0 commit comments

Comments
 (0)