Skip to content

Commit

Permalink
chore: minor clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Oct 3, 2024
1 parent 99cca3d commit 89e005a
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 110 deletions.
1 change: 1 addition & 0 deletions lib/node_modules/@stdlib/array/base/cuany-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function isPositive( value ) {
var x = bernoulli( 10, 0.1 );
console.log( x );

// Cumulatively determine whether at least one element is positive:
var out = cuanyBy( x, isPositive );
console.log( out );
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var isArray = require( '@stdlib/assert/is-array' );
var filled = require( '@stdlib/array/base/filled' );
var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
var pkg = require( '@stdlib/array/base/cuany-by/package.json' ).name;
var cuanyBy = require( '@stdlib/array/base/cuany-by/lib' );
var cuanyBy = require( './../lib' );


// FUNCTIONS //
Expand All @@ -39,7 +39,7 @@ var cuanyBy = require( '@stdlib/array/base/cuany-by/lib' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = filled( 1.5, len );
var x = filled( 0, len );
return benchmark;

/**
Expand Down
3 changes: 3 additions & 0 deletions lib/node_modules/@stdlib/array/base/cuany-by/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
predicate: Function
Predicate function.

thisArg: any (optional)
Execution context.

Returns
-------
y: ArrayLikeObject
Expand Down
22 changes: 19 additions & 3 deletions lib/node_modules/@stdlib/array/base/cuany-by/docs/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,24 @@ function isPositive( value: number ): boolean {
cuanyBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[]
}

// The compiler throws an error if the function is provided a first argument which is not like a function..
// The compiler throws an error if the function is provided a first argument which is not an array-like object...
{
cuanyBy( 1, isPositive ); // $ExpectError
cuanyBy( true, isPositive ); // $ExpectError
cuanyBy( false, isPositive ); // $ExpectError
cuanyBy( null, isPositive ); // $ExpectError
cuanyBy( void 0, isPositive ); // $ExpectError
cuanyBy( {}, isPositive ); // $ExpectError

cuanyBy( 1, isPositive, {} ); // $ExpectError
cuanyBy( true, isPositive, {} ); // $ExpectError
cuanyBy( false, isPositive, {} ); // $ExpectError
cuanyBy( null, isPositive, {} ); // $ExpectError
cuanyBy( void 0, isPositive, {} ); // $ExpectError
cuanyBy( {}, isPositive, {} ); // $ExpectError
}

// The compiler throws an error if the function is provided a second argument which is not function...
{
const x = [ 1, 2, 3, 4 ];

Expand Down Expand Up @@ -147,7 +164,6 @@ function isPositive( value: number ): boolean {
cuanyBy.assign( x, {}, 2, 0, isPositive, {} ); // $ExpectError
}


// The compiler throws an error if the `assign` method is provided a third argument which is not a number...
{
const x = [ false, false, true, false, false ];
Expand Down Expand Up @@ -192,7 +208,7 @@ function isPositive( value: number ): boolean {
cuanyBy.assign( x, y, 1, [], isPositive, {} ); // $ExpectError
}

// The compiler throws an error if the `assign` method is provided a fourth argument which is not like a function...
// The compiler throws an error if the `assign` method is provided a fifth argument which is not like a function...
{
const x = [ false, false, true, false, false ];
const y = [ false, null, false, null, false, null, false, null, false, null ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
'use strict';

var bernoulli = require( '@stdlib/random/array/bernoulli' );
var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' );
var cuanyBy = require( './../lib' );

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

// Create an array of random values:
var x = bernoulli( 10, 0.1 );
console.log( x );

// Cumulatively determine whether values are truthy:
var out = cuanyBy( x, isPositiveInteger );
// Cumulatively determine whether at least one element is positive:
var out = cuanyBy( x, isPositive );
console.log( out );
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/array/base/cuany-by/lib/assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ function indexed( x, y, stride, offset, predicate, thisArg ) {
* @returns {Collection} output array
*
* @example
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
*
* function isPositive( v ) {
* return v > 0;
* }
*
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
*
* var x = toAccessorArray( [ false, false, false, true, false ] );
* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );
*
Expand Down Expand Up @@ -136,7 +136,7 @@ function accessors( x, y, stride, offset, predicate, thisArg ) {
// MAIN //

/**
* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function and assigns results to provided output array.
* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function and assigns results to a provided output array.
*
* @param {Collection} x - input array
* @param {Collection} y - output array
Expand Down
Loading

0 comments on commit 89e005a

Please sign in to comment.