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 89e005a commit ca2fbd0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{{alias}}( x, predicate[, thisArg] )
Cumulatively tests whether at least one array element in a provided array
passes a test implemented by a predicate function, while iterating from
Expand Down Expand Up @@ -27,9 +28,9 @@

Examples
--------
> function isPositive( v ) { return ( v > 0 ); };
> function predicate( v ) { return ( v > 0 ); };
> var x = [ 1, 1, 0, 0, 0 ];
> var y = {{alias}}( x, isPositive )
> var y = {{alias}}( x, predicate )
[ false, false, false, true, true ]


Expand Down Expand Up @@ -71,10 +72,10 @@

Examples
--------
> function isPositive( v ) { return ( v > 0 ); };
> var x = [ 1, 1, 0, 0 ];
> var out = [ false, null, false, null, false, null, false, null ];
> var arr = {{alias}}.assign( x, out, 2, 0, isPositive )
> function predicate( v ) { return ( v > 0 ); };
> var arr = {{alias}}.assign( x, out, 2, 0, predicate )
[ false, null, ..., true, null ]
> var bool = ( arr === out )
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ interface CuanyByRight {
*
* @example
* function isPositive( v ) {
* return v > 0;
* return v > 0;
* }
* var x = [ 1, 1, 0, 0, 0 ];
* var y = [ false, null, false, null, false, null, false, null, false, null ];
Expand Down Expand Up @@ -172,7 +172,7 @@ interface CuanyByRight {
*
* @example
* function isPositive( v ) {
* return v > 0;
* return v > 0;
* }
* var x = [ 1, 1, 0, 0, 0 ];
*
Expand All @@ -181,7 +181,7 @@ interface CuanyByRight {
*
* @example
* function isPositive( v ) {
* return v > 0;
* return v > 0;
* }
* var x = [ 0, 1, 1, 0, 0 ];
* var 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 @@ -16,7 +16,6 @@
* limitations under the License.
*/


import cuanyByRight = require( './index' );

/**
Expand Down Expand Up @@ -57,7 +56,24 @@ function isPositive( value: number ): boolean {
cuanyByRight( 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...
{
cuanyByRight( 1, isPositive ); // $ExpectError
cuanyByRight( true, isPositive ); // $ExpectError
cuanyByRight( false, isPositive ); // $ExpectError
cuanyByRight( null, isPositive ); // $ExpectError
cuanyByRight( void 0, isPositive ); // $ExpectError
cuanyByRight( {}, isPositive ); // $ExpectError

cuanyByRight( 1, isPositive, {} ); // $ExpectError
cuanyByRight( true, isPositive, {} ); // $ExpectError
cuanyByRight( false, isPositive, {} ); // $ExpectError
cuanyByRight( null, isPositive, {} ); // $ExpectError
cuanyByRight( void 0, isPositive, {} ); // $ExpectError
cuanyByRight( {}, 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 @@ -87,7 +103,7 @@ function isPositive( value: number ): boolean {
const y = [ false, null, false, null, false, null, false, null, false, null ];

cuanyByRight.assign( x, y, 2, 0, isPositive ); // $ExpectType (boolean | null)[]
cuanyByRight.assign( x, y, 2, 0, isPositive, {} ); // $ExpectType (boolean | null)[]
cuanyByRight.assign( x, y, 2, 0, isPositive, {} ); // $ExpectType (boolean | null)[]
cuanyByRight.assign( x, new Float64Array( 4 ), 1, 0, isPositive ); // $ExpectType Float64Array
cuanyByRight.assign( x, new Float32Array( 4 ), 1, 0, isPositive ); // $ExpectType Float32Array
cuanyByRight.assign( x, new Int32Array( 4 ), 1, 0, isPositive ); // $ExpectType Int32Array
Expand Down Expand Up @@ -148,7 +164,6 @@ function isPositive( value: number ): boolean {
cuanyByRight.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 @@ -193,7 +208,7 @@ function isPositive( value: number ): boolean {
cuanyByRight.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 @@ -44,14 +44,11 @@
*
* var x = [ 0, 1, 0, 0, 0 ];
*
* var y1 = cuanyByRight( x, isPositive );
* // returns [ false, false, false, true, true ]
*
* var y2 = [ false, null, false, null, false, null, false, null, false, null ];
* var out = cuanyByRight.assign( x, y2, 2, 0, isPositive );
* var y = [ false, null, false, null, false, null, false, null, false, null ];
* var out = cuanyByRight.assign( x, y, 2, 0, isPositive );
* // returns [ false, null, false, null, false, null, true, null, true, null ]
*
* var bool = ( out === y2 );
* var bool = ( out === y );
* // returns true
*/

Expand Down

1 comment on commit ca2fbd0

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
array/base/cuany-by-right $\color{green}295/295$
$\color{green}+100.00\%$
$\color{green}16/16$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}295/295$
$\color{green}+100.00\%$
array/base/cuany-by $\color{green}301/301$
$\color{green}+100.00\%$
$\color{green}17/17$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}301/301$
$\color{green}+100.00\%$
array/base/cuany $\color{green}398/398$
$\color{green}+100.00\%$
$\color{green}32/32$
$\color{green}+100.00\%$
$\color{green}6/6$
$\color{green}+100.00\%$
$\color{green}398/398$
$\color{green}+100.00\%$
array/base/cuevery-by $\color{green}297/297$
$\color{green}+100.00\%$
$\color{green}21/21$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}297/297$
$\color{green}+100.00\%$
array/base/cuevery $\color{green}398/398$
$\color{green}+100.00\%$
$\color{green}32/32$
$\color{green}+100.00\%$
$\color{green}6/6$
$\color{green}+100.00\%$
$\color{green}398/398$
$\color{green}+100.00\%$
array/base/cunone $\color{green}398/398$
$\color{green}+100.00\%$
$\color{green}32/32$
$\color{green}+100.00\%$
$\color{green}6/6$
$\color{green}+100.00\%$
$\color{green}398/398$
$\color{green}+100.00\%$
array/base/cusome $\color{green}416/416$
$\color{green}+100.00\%$
$\color{green}36/36$
$\color{green}+100.00\%$
$\color{green}6/6$
$\color{green}+100.00\%$
$\color{green}416/416$
$\color{green}+100.00\%$
math/base/special/coth $\color{green}164/164$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}164/164$
$\color{green}+100.00\%$
ndarray/base/broadcast-shapes $\color{green}301/301$
$\color{green}+100.00\%$
$\color{green}26/26$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}301/301$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.