Skip to content

Commit f4e8fea

Browse files
committed
Release v0.1.0
1 parent d01e747 commit f4e8fea

File tree

10 files changed

+118
-62
lines changed

10 files changed

+118
-62
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,8 @@ indent_size = 2
179179
[*.gypi]
180180
indent_style = space
181181
indent_size = 2
182+
183+
# Set properties for citation files:
184+
[*.{cff,cff.txt}]
185+
indent_style = space
186+
indent_size = 2

.github/workflows/productionize.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,6 @@ jobs:
8282
id: transform-error-messages
8383
uses: stdlib-js/transform-errors-action@main
8484

85-
# Format error messages:
86-
- name: 'Replace double quotes with single quotes in rewritten format string error messages'
87-
run: |
88-
find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \;
89-
90-
# Format string literal error messages:
91-
- name: 'Replace double quotes with single quotes in rewritten string literal error messages'
92-
run: |
93-
find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \;
94-
95-
# Format code:
96-
- name: 'Replace double quotes with single quotes in inserted `require` calls'
97-
run: |
98-
find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \;
99-
10085
# Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency:
10186
- name: 'Update dependencies in package.json'
10287
run: |

CITATION.cff

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cff-version: 1.2.0
2+
title: stdlib
3+
message: >-
4+
If you use this software, please cite it using the
5+
metadata from this file.
6+
7+
type: software
8+
9+
authors:
10+
- name: The Stdlib Authors
11+
url: https://github.com/stdlib-js/stdlib/graphs/contributors
12+
13+
repository-code: https://github.com/stdlib-js/stdlib
14+
url: https://stdlib.io
15+
16+
abstract: |
17+
Standard library for JavaScript and Node.js.
18+
19+
keywords:
20+
- JavaScript
21+
- Node.js
22+
- TypeScript
23+
- standard library
24+
- scientific computing
25+
- numerical computing
26+
- statistical computing
27+
28+
license: Apache-2.0 AND BSL-1.0
29+
30+
date-released: 2016

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ limitations under the License.
1818
1919
-->
2020

21+
22+
<details>
23+
<summary>
24+
About stdlib...
25+
</summary>
26+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30+
</details>
31+
2132
# doWhileEach
2233

2334
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
@@ -333,8 +344,8 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
333344
[npm-image]: http://img.shields.io/npm/v/@stdlib/utils-do-while-each.svg
334345
[npm-url]: https://npmjs.org/package/@stdlib/utils-do-while-each
335346

336-
[test-image]: https://github.com/stdlib-js/utils-do-while-each/actions/workflows/test.yml/badge.svg?branch=main
337-
[test-url]: https://github.com/stdlib-js/utils-do-while-each/actions/workflows/test.yml?query=branch:main
347+
[test-image]: https://github.com/stdlib-js/utils-do-while-each/actions/workflows/test.yml/badge.svg?branch=v0.1.0
348+
[test-url]: https://github.com/stdlib-js/utils-do-while-each/actions/workflows/test.yml?query=branch:v0.1.0
338349

339350
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-do-while-each/main.svg
340351
[coverage-url]: https://codecov.io/github/stdlib-js/utils-do-while-each?branch=main

dist/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference path="../docs/types/index.d.ts" />
2+
import doWhileEach from '../docs/types/index';
3+
export = doWhileEach;

dist/index.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/types/index.d.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
* limitations under the License.
1717
*/
1818

19-
// TypeScript Version: 2.0
19+
// TypeScript Version: 4.1
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { Collection } from '@stdlib/types/object';
23+
import { Collection } from '@stdlib/types/array';
2424

2525
/**
2626
* Checks whether an element in a collection passes a test.
@@ -35,7 +35,7 @@ type NullaryPredicate = () => boolean;
3535
* @param value - collection value
3636
* @returns boolean indicating whether an element in a collection passes a test
3737
*/
38-
type UnaryPredicate = ( value: any ) => boolean;
38+
type UnaryPredicate<T> = ( value: T ) => boolean;
3939

4040
/**
4141
* Checks whether an element in a collection passes a test.
@@ -44,7 +44,7 @@ type UnaryPredicate = ( value: any ) => boolean;
4444
* @param index - collection index
4545
* @returns boolean indicating whether an element in a collection passes a test
4646
*/
47-
type BinaryPredicate = ( value: any, index: number ) => boolean;
47+
type BinaryPredicate<T> = ( value: T, index: number ) => boolean;
4848

4949
/**
5050
* Checks whether an element in a collection passes a test.
@@ -54,7 +54,7 @@ type BinaryPredicate = ( value: any, index: number ) => boolean;
5454
* @param collection - input collection
5555
* @returns boolean indicating whether an element in a collection passes a test
5656
*/
57-
type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length
57+
type TernaryPredicate<T> = ( value: T, index: number, collection: Collection ) => boolean;
5858

5959
/**
6060
* Checks whether an element in a collection passes a test.
@@ -64,27 +64,27 @@ type TernaryPredicate = ( value: any, index: number, collection: Collection ) =>
6464
* @param collection - input collection
6565
* @returns boolean indicating whether an element in a collection passes a test
6666
*/
67-
type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length
67+
type Predicate<T> = NullaryPredicate | UnaryPredicate<T> | BinaryPredicate<T> | TernaryPredicate<T>;
6868

6969
/**
7070
* Function invoked for each collection element while a test condition is true.
7171
*/
72-
type Nullary = () => void;
72+
type Nullary<U> = ( this: U ) => void;
7373

7474
/**
7575
* Function invoked for each collection element while a test condition is true.
7676
*
7777
* @param value - collection value
7878
*/
79-
type Unary = ( value: any ) => void;
79+
type Unary<T, U> = ( this: U, value: T ) => void;
8080

8181
/**
8282
* Function invoked for each collection element while a test condition is true.
8383
*
8484
* @param value - collection value
8585
* @param index - collection index
8686
*/
87-
type Binary = ( value: any, index: number ) => void;
87+
type Binary<T, U> = ( this: U, value: T, index: number ) => void;
8888

8989
/**
9090
* Function invoked for each collection element while a test condition is true.
@@ -93,7 +93,7 @@ type Binary = ( value: any, index: number ) => void;
9393
* @param index - collection index
9494
* @param collection - input collection
9595
*/
96-
type Ternary = ( value: any, index: number, collection: Collection ) => void;
96+
type Ternary<T, U> = ( this: U, value: T, index: number, collection: Collection<T> ) => void;
9797

9898
/**
9999
* Function invoked for each collection element while a test condition is true.
@@ -102,7 +102,7 @@ type Ternary = ( value: any, index: number, collection: Collection ) => void;
102102
* @param index - collection index
103103
* @param collection - input collection
104104
*/
105-
type Callback = Nullary | Unary | Binary | Ternary;
105+
type Callback<T, U> = Nullary<U> | Unary<T, U> | Binary<T, U> | Ternary<T, U>;
106106

107107
/**
108108
* While a test condition is true, invokes a function once for each element in a collection.
@@ -139,7 +139,7 @@ type Callback = Nullary | Unary | Binary | Ternary;
139139
*
140140
* doWhileEach( arr, log, predicate );
141141
*/
142-
declare function doWhileEach( collection: Collection, fcn: Callback, predicate: Predicate, thisArg?: any ): Collection; // tslint-disable-line max-line-length
142+
declare function doWhileEach<T = unknown, U = unknown>( collection: Collection<T>, fcn: Callback<T, U>, predicate: Predicate<T>, thisArg?: ThisParameterType<Callback<T, U>> ): Collection<T>;
143143

144144

145145
// EXPORTS //

docs/types/test.ts

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,38 @@
1818

1919
import doWhileEach = require( './index' );
2020

21-
const log = ( v: any, index: number ): void => {
22-
console.log( `${index}: ${v}` );
23-
};
21+
/**
22+
* Dummy function.
23+
*/
24+
function fcn( v: any, index: number ): number {
25+
if ( v !== v ) {
26+
throw new Error( 'beep' );
27+
}
28+
return index;
29+
}
2430

25-
const isNotNaN = ( v: number ): boolean => {
31+
/**
32+
* Dummy function.
33+
*/
34+
function isNotNaN( v: number ): boolean {
2635
return ( v === v );
27-
};
36+
}
37+
2838

2939
// TESTS //
3040

3141
// The function returns the input collection...
3242
{
33-
doWhileEach( [ 0, 1, 1, NaN, 2 ], log, isNotNaN ); // $ExpectType Collection
34-
doWhileEach( [ -1, 1, 2 ], log, isNotNaN, {} ); // $ExpectType Collection
43+
doWhileEach( [ 0, 1, 1, NaN, 2 ], fcn, isNotNaN ); // $ExpectType Collection<number>
44+
doWhileEach( [ -1, 1, 2 ], fcn, isNotNaN, {} ); // $ExpectType Collection<number>
3545
}
3646

3747
// The compiler throws an error if the function is provided a first argument which is not a collection...
3848
{
39-
doWhileEach( 2, log, isNotNaN ); // $ExpectError
40-
doWhileEach( false, log, isNotNaN ); // $ExpectError
41-
doWhileEach( true, log, isNotNaN ); // $ExpectError
42-
doWhileEach( {}, log, isNotNaN ); // $ExpectError
49+
doWhileEach( 2, fcn, isNotNaN ); // $ExpectError
50+
doWhileEach( false, fcn, isNotNaN ); // $ExpectError
51+
doWhileEach( true, fcn, isNotNaN ); // $ExpectError
52+
doWhileEach( {}, fcn, isNotNaN ); // $ExpectError
4353
}
4454

4555
// The compiler throws an error if the function is provided a second argument which is not a function...
@@ -54,18 +64,18 @@ const isNotNaN = ( v: number ): boolean => {
5464

5565
// The compiler throws an error if the function is provided a third argument which is not a function...
5666
{
57-
doWhileEach( [ 0, 1, 1, NaN, 2 ], log, 2 ); // $ExpectError
58-
doWhileEach( [ 0, 1, 1, NaN, 2 ], log, false ); // $ExpectError
59-
doWhileEach( [ 0, 1, 1, NaN, 2 ], log, true ); // $ExpectError
60-
doWhileEach( [ 0, 1, 1, NaN, 2 ], log, 'abc' ); // $ExpectError
61-
doWhileEach( [ 0, 1, 1, NaN, 2 ], log, {} ); // $ExpectError
62-
doWhileEach( [ 0, 1, 1, NaN, 2 ], log, [] ); // $ExpectError
67+
doWhileEach( [ 0, 1, 1, NaN, 2 ], fcn, 2 ); // $ExpectError
68+
doWhileEach( [ 0, 1, 1, NaN, 2 ], fcn, false ); // $ExpectError
69+
doWhileEach( [ 0, 1, 1, NaN, 2 ], fcn, true ); // $ExpectError
70+
doWhileEach( [ 0, 1, 1, NaN, 2 ], fcn, 'abc' ); // $ExpectError
71+
doWhileEach( [ 0, 1, 1, NaN, 2 ], fcn, {} ); // $ExpectError
72+
doWhileEach( [ 0, 1, 1, NaN, 2 ], fcn, [] ); // $ExpectError
6373
}
6474

6575
// The compiler throws an error if the function is provided an invalid number of arguments...
6676
{
6777
doWhileEach(); // $ExpectError
6878
doWhileEach( [ 1, 2, 3 ] ); // $ExpectError
69-
doWhileEach( [ 1, 2, 3 ], log ); // $ExpectError
70-
doWhileEach( [ 1, 2, 3 ], log, isNotNaN, {}, 3 ); // $ExpectError
79+
doWhileEach( [ 1, 2, 3 ], fcn ); // $ExpectError
80+
doWhileEach( [ 1, 2, 3 ], fcn, isNotNaN, {}, 3 ); // $ExpectError
7181
}

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stdlib/utils-do-while-each",
3-
"version": "0.0.8",
3+
"version": "0.1.0",
44
"description": "While a test condition is true, invoke a function for each element in a collection.",
55
"license": "Apache-2.0",
66
"author": {
@@ -37,22 +37,22 @@
3737
"url": "https://github.com/stdlib-js/stdlib/issues"
3838
},
3939
"dependencies": {
40-
"@stdlib/assert-is-collection": "^0.0.8",
41-
"@stdlib/assert-is-function": "^0.0.8",
42-
"@stdlib/string-format": "^0.0.3",
43-
"@stdlib/types": "^0.0.14"
40+
"@stdlib/assert-is-collection": "^0.1.0",
41+
"@stdlib/assert-is-function": "^0.1.0",
42+
"@stdlib/string-format": "^0.1.0",
43+
"@stdlib/types": "^0.1.0"
4444
},
4545
"devDependencies": {
46-
"@stdlib/array-float32": "^0.0.6",
47-
"@stdlib/array-float64": "^0.0.6",
48-
"@stdlib/assert-is-even": "^0.0.8",
49-
"@stdlib/assert-is-nan": "^0.0.8",
50-
"@stdlib/bench": "^0.0.12",
51-
"@stdlib/constants-float64-pinf": "^0.0.8",
52-
"@stdlib/math-base-assert-is-nan": "^0.0.8",
53-
"@stdlib/math-base-special-floor": "^0.0.8",
46+
"@stdlib/array-float32": "^0.1.0",
47+
"@stdlib/array-float64": "^0.1.0",
48+
"@stdlib/assert-is-even": "^0.1.0",
49+
"@stdlib/assert-is-nan": "^0.1.0",
50+
"@stdlib/bench": "^0.1.0",
51+
"@stdlib/constants-float64-pinf": "^0.1.0",
52+
"@stdlib/math-base-assert-is-nan": "^0.1.0",
53+
"@stdlib/math-base-special-floor": "^0.1.0",
5454
"@stdlib/random-base-randu": "^0.0.8",
55-
"@stdlib/utils-noop": "^0.0.14",
55+
"@stdlib/utils-noop": "^0.1.0",
5656
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
5757
"istanbul": "^0.4.1",
5858
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"

0 commit comments

Comments
 (0)