Skip to content

Commit 79ca598

Browse files
committed
Auto-generated commit
1 parent 79027fe commit 79ca598

File tree

8 files changed

+102
-47
lines changed

8 files changed

+102
-47
lines changed

.editorconfig

+5
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

-15
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

+30
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

+19-8
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
# forEachAsync
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] -->
@@ -91,9 +102,9 @@ forEachAsync( arr, onDuration, done );
91102

92103
The function accepts the following `options`:
93104

94-
- `limit`: the maximum number of pending invocations at any one time. Default: `infinity`.
95-
- `series`: `boolean` indicating whether to sequentially invoke `fcn` for each `collection` element. If `true`, the function sets `options.limit=1`. Default: `false`.
96-
- `thisArg`: the execution context for `fcn`.
105+
- **limit**: the maximum number of pending invocations at any one time. Default: `infinity`.
106+
- **series**: boolean indicating whether to sequentially invoke `fcn` for each `collection` element. If `true`, the function sets `options.limit=1`. Default: `false`.
107+
- **thisArg**: the execution context for `fcn`.
97108

98109
By default, all elements are processed concurrently, which means that the function does **not** guarantee completion order. To process each `collection` element sequentially, set the `series` option to `true`.
99110

@@ -191,10 +202,10 @@ function done( error ) {
191202

192203
When invoked, `fcn` is provided a maximum of four arguments:
193204

194-
- `value`: collection value.
195-
- `index`: collection index.
196-
- `collection`: the input `collection`.
197-
- `next`: a callback which should be called once `fcn` has finished processing a collection `value`.
205+
- **value**: collection value.
206+
- **index**: collection index.
207+
- **collection**: the input `collection`.
208+
- **next**: a callback which should be called once `fcn` has finished processing a collection `value`.
198209

199210
The actual number of provided arguments depends on function `length`. If `fcn` accepts two arguments, `fcn` is provided `value` and `next`. If `fcn` accepts three arguments, `fcn` is provided `value`, `index`, and `next`. For every other `fcn` signature, `fcn` is provided all four arguments.
200211

@@ -229,7 +240,7 @@ forEachAsync( arr, onDuration, done );
229240

230241
#### forEachAsync.factory( \[options,] fcn )
231242

232-
Returns a `function` which invokes a function once for each element in a `collection`.
243+
Returns a function which invokes a function once for each element in a `collection`.
233244

234245
```javascript
235246
function onDuration( value, next ) {

dist/index.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference path="../docs/types/index.d.ts" />
2+
import forEachAsync from '../docs/types/index';
3+
export = forEachAsync;

dist/index.js

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/types/index.d.ts

+27-24
Original file line numberDiff line numberDiff line change
@@ -16,58 +16,65 @@
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
* Interface defining function options.
2727
*/
28-
interface Options {
28+
interface Options<T, V> {
2929
/**
30-
* The maximum number of pending invocations at any one time.
30+
* Execution context.
3131
*/
32-
limit?: number;
32+
thisArg?: ThisParameterType<Fcn<T, V>>;
3333

3434
/**
35-
* Boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection (default: false).
35+
* The maximum number of pending invocations at any one time.
3636
*/
37-
series?: boolean;
37+
limit?: number;
3838

3939
/**
40-
* Execution context.
40+
* Boolean indicating whether to sequentially invoke the provided function for each `collection` element. If `true`, the function sets `options.limit=1`. Default: false.
4141
*/
42-
thisArg?: any;
42+
series?: boolean;
4343
}
4444

4545
/**
4646
* Callback function.
4747
*/
48-
type NullaryCallback = () => void;
48+
type Nullary = () => void;
4949

5050
/**
5151
* Callback function.
5252
*
5353
* @param error - encountered error
5454
*/
55-
type UnaryCallback = ( error: Error ) => void;
55+
type Unary = ( error: Error ) => void;
5656

5757
/**
5858
* Callback function.
5959
*
6060
* @param error - encountered error
6161
*/
62-
type Callback = NullaryCallback | UnaryCallback;
62+
type Callback = Nullary | Unary;
63+
64+
/**
65+
* Callback function to invoke once the provided function has finished processing a collection value.
66+
*
67+
* @param error - encountered error
68+
*/
69+
type Next = Nullary | Unary;
6370

6471
/**
6572
* Function invoked for each element in a collection.
6673
*
6774
* @param value - collection value
6875
* @param next - a callback to be invoked after processing a collection `value`
6976
*/
70-
type Binary = ( value: any, next: Callback ) => void;
77+
type BinaryFcn<T, V> = ( this: V, value: T, next: Next ) => void;
7178

7279
/**
7380
* Function invoked for each element in a collection.
@@ -76,7 +83,7 @@ type Binary = ( value: any, next: Callback ) => void;
7683
* @param index - collection index
7784
* @param next - a callback to be invoked after processing a collection `value`
7885
*/
79-
type Ternary = ( value: any, index: number, next: Callback ) => void;
86+
type TernaryFcn<T, V> = ( this: V, value: T, index: number, next: Next ) => void;
8087

8188
/**
8289
* Function invoked for each element in a collection.
@@ -86,7 +93,7 @@ type Ternary = ( value: any, index: number, next: Callback ) => void;
8693
* @param collection - input collection
8794
* @param next - a callback to be invoked after processing a collection `value`
8895
*/
89-
type Quaternary = ( value: any, index: number, collection: Collection, next: Callback ) => void; // tslint-disable-line max-line-length
96+
type QuaternaryFcn<T, V> = ( this: V, value: T, index: number, collection: Collection<T>, next: Next ) => void;
9097

9198
/**
9299
* Function invoked for each element in a collection.
@@ -96,7 +103,7 @@ type Quaternary = ( value: any, index: number, collection: Collection, next: Cal
96103
* @param collection - input collection
97104
* @param next - a callback to be invoked after processing a collection `value`
98105
*/
99-
type Fcn = Binary | Ternary | Quaternary;
106+
type Fcn<T, V> = BinaryFcn<T, V> | TernaryFcn<T, V> | QuaternaryFcn<T, V>;
100107

101108
/**
102109
* Function which invokes the provided function once for each element in a collection.
@@ -118,7 +125,6 @@ interface ForEachAsync {
118125
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.
119126
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
120127
*
121-
*
122128
* @param collection - input collection
123129
* @param options - function options
124130
* @param options.thisArg - execution context
@@ -160,7 +166,7 @@ interface ForEachAsync {
160166
*
161167
* forEachAsync( files, read, done );
162168
*/
163-
( collection: Collection, options: Options, fcn: Fcn, done: Callback ): void; // tslint-disable-line max-line-length
169+
<T = unknown, V = unknown>( collection: Collection<T>, options: Options<T, V>, fcn: Fcn<T, V>, done: Callback ): void;
164170

165171
/**
166172
* Invokes a function once for each element in a collection.
@@ -170,7 +176,6 @@ interface ForEachAsync {
170176
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.
171177
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
172178
*
173-
*
174179
* @param collection - input collection
175180
* @param options - function options
176181
* @param options.thisArg - execution context
@@ -212,7 +217,7 @@ interface ForEachAsync {
212217
*
213218
* forEachAsync( files, read, done );
214219
*/
215-
( collection: Collection, fcn: Fcn, done: Callback ): void;
220+
<T = unknown, V = unknown>( collection: Collection<T>, fcn: Fcn<T, V>, done: Callback ): void; // tslint:disable-line:no-unnecessary-generics
216221

217222
/**
218223
* Returns a function to invoke a function once for each element in a collection.
@@ -222,7 +227,6 @@ interface ForEachAsync {
222227
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.
223228
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
224229
*
225-
*
226230
* @param options - function options
227231
* @param options.thisArg - execution context
228232
* @param options.limit - maximum number of pending invocations at any one time
@@ -273,7 +277,7 @@ interface ForEachAsync {
273277
* // Run `read` for each element in `files`:
274278
* forEachAsync( files, done );
275279
*/
276-
factory( options: Options, fcn: Fcn ): FactoryFunction;
280+
factory<T = unknown, V = unknown>( options: Options<T, V>, fcn: Fcn<T, V> ): FactoryFunction;
277281

278282
/**
279283
* Returns a function to invoke a function once for each element in a collection.
@@ -324,7 +328,7 @@ interface ForEachAsync {
324328
* // Run `read` for each element in `files`:
325329
* forEachAsync( files, done );
326330
*/
327-
factory( fcn: Fcn ): FactoryFunction;
331+
factory<T = unknown, V = unknown>( fcn: Fcn<T, V> ): FactoryFunction; // tslint:disable-line:no-unnecessary-generics
328332
}
329333

330334
/**
@@ -335,7 +339,6 @@ interface ForEachAsync {
335339
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.
336340
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
337341
*
338-
*
339342
* @param collection - input collection
340343
* @param options - function options
341344
* @param options.thisArg - execution context

0 commit comments

Comments
 (0)