From fdcb3e06cce4887a682e17228e9b30bb8b5b20e3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 08:11:31 +0000 Subject: [PATCH] Auto-generated commit --- .github/workflows/publish.yml | 2 +- CONTRIBUTORS | 4 ++ while-each-right/docs/types/index.d.ts | 18 ++++----- while-each-right/docs/types/test.ts | 53 ++++++++++++++------------ 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f56d473a..26be02d3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -197,7 +197,7 @@ jobs: # Publish package to npm: - name: 'Publish package to npm' - uses: JS-DevTools/npm-publish@v1 + uses: JS-DevTools/npm-publish@v2 with: token: ${{ secrets.NPM_TOKEN }} access: public diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a9844390..0c2727bb 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -16,19 +16,23 @@ Joey Reed Jordan-Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com> Joris Labie Justin Dennison +KATTA NAGA NITHIN <88046362+nithinkatta@users.noreply.github.com> Marcus Matt Cochrane Milan Raj Momtchil Momtchev +Naresh Jagadeesan <37257700+Infinage@users.noreply.github.com> Ognjen Jevremović Philipp Burckhardt Pranav <85227306+Pranavchiku@users.noreply.github.com> Ricky Reusser +Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> Ryan Seal Seyyed Parsa Neshaei Shraddheya Shendre Stephannie Jiménez Gacha Yernar Yergaziyev dorrin-sot <59933477+dorrin-sot@users.noreply.github.com> +drunken_devv <90555965+amitjimiwal@users.noreply.github.com> orimiles5 <97595296+orimiles5@users.noreply.github.com> rei2hu diff --git a/while-each-right/docs/types/index.d.ts b/while-each-right/docs/types/index.d.ts index d591962e..0c6a681f 100644 --- a/while-each-right/docs/types/index.d.ts +++ b/while-each-right/docs/types/index.d.ts @@ -35,7 +35,7 @@ type NullaryPredicate = () => boolean; * @param value - collection value * @returns boolean indicating whether an element in a collection passes a test */ -type UnaryPredicate = ( value: any ) => boolean; +type UnaryPredicate = ( value: T ) => boolean; /** * Checks whether an element in a collection passes a test. @@ -44,7 +44,7 @@ type UnaryPredicate = ( value: any ) => boolean; * @param index - collection index * @returns boolean indicating whether an element in a collection passes a test */ -type BinaryPredicate = ( value: any, index: number ) => boolean; +type BinaryPredicate = ( value: T, index: number ) => boolean; /** * Checks whether an element in a collection passes a test. @@ -54,7 +54,7 @@ type BinaryPredicate = ( value: any, index: number ) => boolean; * @param collection - input collection * @returns boolean indicating whether an element in a collection passes a test */ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length +type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length /** * Checks whether an element in a collection passes a test. @@ -64,7 +64,7 @@ type TernaryPredicate = ( value: any, index: number, collection: Collection ) => * @param collection - input collection * @returns boolean indicating whether an element in a collection passes a test */ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length +type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length /** * Function invoked for each collection element passing a test. @@ -76,7 +76,7 @@ type Nullary = () => void; * * @param value - collection value */ -type Unary = ( value: any ) => void; +type Unary = ( value: T ) => void; /** * Function invoked for each collection element passing a test. @@ -84,7 +84,7 @@ type Unary = ( value: any ) => void; * @param value - collection value * @param index - collection index */ -type Binary = ( value: any, index: number ) => void; +type Binary = ( value: T, index: number ) => void; /** * Function invoked for each collection element passing a test. @@ -93,7 +93,7 @@ type Binary = ( value: any, index: number ) => void; * @param index - collection index * @param collection - input collection */ -type Ternary = ( value: any, index: number, collection: Collection ) => void; +type Ternary = ( value: T, index: number, collection: Collection ) => void; // tslint-disable-line max-line-length /** * Function invoked for each collection element passing a test. @@ -102,7 +102,7 @@ type Ternary = ( value: any, index: number, collection: Collection ) => void; * @param index - collection index * @param collection - input collection */ -type Callback = Nullary | Unary | Binary | Ternary; +type Callback = Nullary | Unary | Binary | Ternary; /** * While a test condition is true, invokes a function once for each element in a collection, iterating from right to left. @@ -137,7 +137,7 @@ type Callback = Nullary | Unary | Binary | Ternary; * * whileEachRight( arr, predicate, log ); */ -declare function whileEachRight( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length +declare function whileEachRight( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length // EXPORTS // diff --git a/while-each-right/docs/types/test.ts b/while-each-right/docs/types/test.ts index 1ccee1de..fd6942bd 100644 --- a/while-each-right/docs/types/test.ts +++ b/while-each-right/docs/types/test.ts @@ -18,54 +18,59 @@ import whileEachRight = require( './index' ); -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); +const fcn = ( v: number, index: number ): void => { + if ( v !== v ) { + throw new Error( 'beep' ); + } + if ( index !== index ) { + throw new Error( 'beep' ); + } }; -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); +const isnan = ( v: number ): boolean => { + return ( v !== v ); }; // TESTS // // The function returns the input collection... { - whileEachRight( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - whileEachRight( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection + whileEachRight( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection + whileEachRight( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection } // The compiler throws an error if the function is provided a first argument which is not a collection... { - whileEachRight( 2, isNotNaN, log ); // $ExpectError - whileEachRight( false, isNotNaN, log ); // $ExpectError - whileEachRight( true, isNotNaN, log ); // $ExpectError - whileEachRight( {}, isNotNaN, log ); // $ExpectError + whileEachRight( 2, isnan, fcn ); // $ExpectError + whileEachRight( false, isnan, fcn ); // $ExpectError + whileEachRight( true, isnan, fcn ); // $ExpectError + whileEachRight( {}, isnan, fcn ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a function... { - whileEachRight( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a function... { - whileEachRight( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - whileEachRight( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError + whileEachRight( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError } // The compiler throws an error if the function is provided an invalid number of arguments... { whileEachRight(); // $ExpectError whileEachRight( [ 1, 2, 3 ] ); // $ExpectError - whileEachRight( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - whileEachRight( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError + whileEachRight( [ 1, 2, 3 ], isnan ); // $ExpectError + whileEachRight( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError }