Skip to content

Commit

Permalink
chore: move functions to parent scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Sep 26, 2024
1 parent 6207381 commit f477e26
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ var detect = require( './../lib' );
var hasSharedArrayBuffer = ( typeof SharedArrayBuffer === 'function' ); // eslint-disable-line stdlib/require-globals


// FUNCTIONS //

function isBufferMock() {
return true;
}


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down Expand Up @@ -78,15 +85,11 @@ tape( 'if `SharedArrayBuffer` is supported, detection result is `true`', functio

mocked = proxyquire( './../lib/main.js', {
'./sharedarraybuffer.js': Mock,
'@stdlib/assert/is-sharedarraybuffer': isBuffer
'@stdlib/assert/is-sharedarraybuffer': isBufferMock
});
t.strictEqual( mocked(), true, 'detection result is `true` (mocked)' );

t.end();

function isBuffer() {
return true;
}
});

tape( 'if `SharedArrayBuffer` is not supported, detection result is `false` (no SharedArrayBuffer global function)', function test( t ) {
Expand Down Expand Up @@ -141,14 +144,10 @@ tape( 'if `SharedArrayBuffer` is not supported, detected result is `false` (no s
}
mocked = proxyquire( './../lib/main.js', {
'./sharedarraybuffer.js': Mock,
'@stdlib/assert/is-sharedarraybuffer': isBuffer
'@stdlib/assert/is-sharedarraybuffer': isBufferMock
});
t.strictEqual( mocked(), false, 'detection result is `false`' );
t.end();

function isBuffer() {
return true;
}
});

tape( 'if `SharedArrayBuffer` is not supported, detected result is `false` (no byteLength property)', function test( t ) {
Expand Down Expand Up @@ -183,12 +182,8 @@ tape( 'if `SharedArrayBuffer` is not supported, detected result is `false` (no b
}
mocked = proxyquire( './../lib/main.js', {
'./sharedarraybuffer.js': Mock,
'@stdlib/assert/is-sharedarraybuffer': isBuffer
'@stdlib/assert/is-sharedarraybuffer': isBufferMock
});
t.strictEqual( mocked(), false, 'detection result is `false`' );
t.end();

function isBuffer() {
return true;
}
});
35 changes: 11 additions & 24 deletions lib/node_modules/@stdlib/utils/any-by-right/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ var Float64Array = require( '@stdlib/array/float64' );
var anyByRight = require( './../lib' );


// FUNCTIONS //

function isPositive( value ) {
return ( value > 0 );
}

function isNegative( value ) {
return ( value < 0 );
}


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down Expand Up @@ -114,10 +125,6 @@ tape( 'the function returns `true` if at least one element passes a test (array)

arr = [ -1, 1, 2, 3 ];

function isNegative( value ) {
return ( value < 0 );
}

bool = anyByRight( arr, isNegative );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -130,10 +137,6 @@ tape( 'the function returns `false` if all elements fail a test (array)', functi

arr = [ -1, -2, -3 ];

function isPositive( value ) {
return ( value > 0 );
}

bool = anyByRight( arr, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand All @@ -152,10 +155,6 @@ tape( 'the function returns `true` if at least one element passes a test (array-
'3': 4
};

function isNegative( value ) {
return ( value < 0 );
}

bool = anyByRight( arr, isNegative );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -173,10 +172,6 @@ tape( 'the function returns `false` if all elements fail a test (array-like obje
'2': -3
};

function isPositive( value ) {
return ( value > 0 );
}

bool = anyByRight( arr, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand All @@ -189,10 +184,6 @@ tape( 'the function returns `true` if at least one element passes a test (typed

arr = new Float64Array( [ -1.0, 2.0, 3.0, 4.0 ] );

function isNegative( value ) {
return ( value < 0 );
}

bool = anyByRight( arr, isNegative );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -205,10 +196,6 @@ tape( 'the function returns `false` if all elements fail a test (typed array)',

arr = new Float64Array( [ -1.0, -2.0, -3.0 ] );

function isPositive( value ) {
return ( value > 0 );
}

bool = anyByRight( arr, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand Down
35 changes: 11 additions & 24 deletions lib/node_modules/@stdlib/utils/any-by/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ var Float64Array = require( '@stdlib/array/float64' );
var anyBy = require( './../lib' );


// FUNCTIONS //

function isPositive( value ) {
return ( value > 0 );
}

function isNegative( value ) {
return ( value < 0 );
}


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down Expand Up @@ -114,10 +125,6 @@ tape( 'the function returns `true` if at least one element passes a test (array)

arr = [ 1, 2, 3, -1 ];

function isNegative( value ) {
return ( value < 0 );
}

bool = anyBy( arr, isNegative );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -130,10 +137,6 @@ tape( 'the function returns `false` if all elements fail a test (array)', functi

arr = [ -1, -2, -3 ];

function isPositive( value ) {
return ( value > 0 );
}

bool = anyBy( arr, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand All @@ -152,10 +155,6 @@ tape( 'the function returns `true` if at least one element passes a test (array-
'3': -1
};

function isNegative( value ) {
return ( value < 0 );
}

bool = anyBy( arr, isNegative );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -173,10 +172,6 @@ tape( 'the function returns `false` if all elements fail a test (array-like obje
'2': -3
};

function isPositive( value ) {
return ( value > 0 );
}

bool = anyBy( arr, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand All @@ -189,10 +184,6 @@ tape( 'the function returns `true` if at least one element passes a test (typed

arr = new Float64Array( [ 1.0, 2.0, 3.0, -1.0 ] );

function isNegative( value ) {
return ( value < 0 );
}

bool = anyBy( arr, isNegative );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -205,10 +196,6 @@ tape( 'the function returns `false` if all elements fail a test (typed array)',

arr = new Float64Array( [ -1.0, -2.0, -3.0 ] );

function isPositive( value ) {
return ( value > 0 );
}

bool = anyBy( arr, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand Down
15 changes: 7 additions & 8 deletions lib/node_modules/@stdlib/utils/any-own-by/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ var noop = require( '@stdlib/utils/noop' );
var anyOwnBy = require( './../lib' );


// FUNCTIONS //

function isPositive( v ) {
return ( v > 0 );
}


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down Expand Up @@ -116,10 +123,6 @@ tape( 'the function returns `true` if any one property pass a test', function te
'c': -3
};

function isPositive( v ) {
return ( v > 0 );
}

bool = anyOwnBy( obj, isPositive );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -137,10 +140,6 @@ tape( 'the function returns `false` if no properties pass a test', function test
'd': -34
};

function isPositive( v ) {
return ( v > 0 );
}

bool = anyOwnBy( obj, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand Down
31 changes: 7 additions & 24 deletions lib/node_modules/@stdlib/utils/every-by-right/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ var Float64Array = require( '@stdlib/array/float64' );
var everyByRight = require( './../lib' );


// FUNCTIONS //

function isPositive( value ) {
return ( value > 0 );
}


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down Expand Up @@ -114,10 +121,6 @@ tape( 'the function returns `true` if all elements pass a test (array)', functio

arr = [ 1, 2, 3 ];

function isPositive( value ) {
return ( value > 0 );
}

bool = everyByRight( arr, isPositive );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -130,10 +133,6 @@ tape( 'the function returns `false` if one or more elements fail a test (array)'

arr = [ 1, -2, 3 ];

function isPositive( value ) {
return ( value > 0 );
}

bool = everyByRight( arr, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand All @@ -151,10 +150,6 @@ tape( 'the function returns `true` if all elements pass a test (array-like objec
'2': 3
};

function isPositive( value ) {
return ( value > 0 );
}

bool = everyByRight( arr, isPositive );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -172,10 +167,6 @@ tape( 'the function returns `false` if one or more elements fail a test (array-l
'2': 3
};

function isPositive( value ) {
return ( value > 0 );
}

bool = everyByRight( arr, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand All @@ -188,10 +179,6 @@ tape( 'the function returns `true` if all elements pass a test (typed array)', f

arr = new Float64Array( [ 1.0, 2.0, 3.0 ] );

function isPositive( value ) {
return ( value > 0 );
}

bool = everyByRight( arr, isPositive );

t.strictEqual( bool, true, 'returns true' );
Expand All @@ -204,10 +191,6 @@ tape( 'the function returns `false` if one or more elements fail a test (typed a

arr = new Float64Array( [ 1.0, -2.0, 3.0 ] );

function isPositive( value ) {
return ( value > 0 );
}

bool = everyByRight( arr, isPositive );

t.strictEqual( bool, false, 'returns false' );
Expand Down
Loading

0 comments on commit f477e26

Please sign in to comment.