Skip to content

Commit 6066ec5

Browse files
committed
Auto-generated commit
1 parent 389d09a commit 6066ec5

File tree

9 files changed

+102
-56
lines changed

9 files changed

+102
-56
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
# inmapRightAsync
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] -->
@@ -146,9 +157,9 @@ inmapRightAsync( arr, fcn, done );
146157

147158
The function accepts the following `options`:
148159

149-
- `limit`: the maximum number of pending invocations at any one time. Default: `infinity`.
150-
- `series`: `boolean` indicating whether to sequentially invoke `fcn` for each `collection` element. If `true`, the function sets `options.limit=1`. Default: `false`.
151-
- `thisArg`: the execution context for `fcn`.
160+
- **limit**: the maximum number of pending invocations at any one time. Default: `infinity`.
161+
- **series**: boolean indicating whether to sequentially invoke `fcn` for each `collection` element. If `true`, the function sets `options.limit=1`. Default: `false`.
162+
- **thisArg**: the execution context for `fcn`.
152163

153164
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`.
154165

@@ -266,10 +277,10 @@ function done( error, collection ) {
266277

267278
When invoked, `fcn` is provided a maximum of four arguments:
268279

269-
- `value`: collection value.
270-
- `index`: collection index.
271-
- `collection`: the input `collection`.
272-
- `next`: a callback which should be called once `fcn` has finished processing a collection `value`.
280+
- **value**: collection value.
281+
- **index**: collection index.
282+
- **collection**: the input `collection`.
283+
- **next**: a callback which should be called once `fcn` has finished processing a collection `value`.
273284

274285
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.
275286

@@ -310,7 +321,7 @@ inmapRightAsync( arr, fcn, done );
310321

311322
#### inmapRightAsync.factory( \[options,] fcn )
312323

313-
Returns a `function` which invokes a function once for each element in a `collection`, iterating from right to left.
324+
Returns a function which invokes a function once for each element in a `collection`, iterating from right to left.
314325

315326
```javascript
316327
function fcn( value, index, 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 inmapRightAsync from '../docs/types/index';
3+
export = inmapRightAsync;

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

+25-31
Original file line numberDiff line numberDiff line change
@@ -16,91 +16,90 @@
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, U, 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, U, 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 invoked either upon processing all collection elements or upon encountering an error.
4747
*/
48-
type DoneNullary = () => void;
48+
type Nullary = () => void;
4949

5050
/**
5151
* Callback invoked either upon processing all collection elements or upon encountering an error.
5252
*
5353
* @param error - error argument
5454
*/
55-
type DoneUnary = ( error: Error ) => void;
55+
type Unary = ( error: Error ) => void;
5656

5757
/**
5858
* Callback invoked either upon processing all collection elements or upon encountering an error.
5959
*
6060
* @param error - error argument
6161
* @param collection - updated input collection
6262
*/
63-
type DoneBinary = ( error: Error, collection: Collection ) => void;
63+
type Binary<U> = ( error: Error, collection: Collection<U> ) => void;
6464

6565
/**
6666
* Callback invoked either upon processing all collection elements or upon encountering an error.
6767
*
6868
* @param error - error argument
6969
* @param collection - updated input collection
7070
*/
71-
type DoneCallback = DoneNullary | DoneUnary | DoneBinary;
71+
type Callback<U> = Nullary | Unary | Binary<U>;
7272

7373
/**
7474
* Callback function.
7575
*
7676
* @param error - error argument
77-
* @param result - value used to update the collection
7877
*/
79-
type Unary = ( error: Error ) => void;
78+
type UnaryNext = ( error: Error ) => void;
8079

8180
/**
8281
* Callback function.
8382
*
8483
* @param error - error argument
8584
* @param result - value used to update the collection
8685
*/
87-
type Binary = ( error: Error | null, result: any ) => void;
86+
type BinaryNext<U> = ( error: Error | null, result: U ) => void;
8887

8988
/**
9089
* Callback function.
9190
*
9291
* @param error - error argument
9392
* @param result - value used to update the collection
9493
*/
95-
type Callback = Unary | Binary;
94+
type Next<U> = UnaryNext | BinaryNext<U>;
9695

9796
/**
9897
* Function invoked for each element in a collection.
9998
*
10099
* @param value - collection value
101100
* @param next - a callback to be invoked after processing a collection `value`
102101
*/
103-
type BinaryFcn = ( value: any, next: Callback ) => void;
102+
type BinaryFcn<T, U, V> = ( this: V, value: T, next: Next<U> ) => void;
104103

105104
/**
106105
* Function invoked for each element in a collection.
@@ -109,7 +108,7 @@ type BinaryFcn = ( value: any, next: Callback ) => void;
109108
* @param index - collection index
110109
* @param next - a callback to be invoked after processing a collection `value`
111110
*/
112-
type TernaryFcn = ( value: any, index: number, next: Callback ) => void;
111+
type TernaryFcn<T, U, V> = ( this: V, value: T, index: number, next: Next<U> ) => void;
113112

114113
/**
115114
* Function invoked for each element in a collection.
@@ -119,7 +118,7 @@ type TernaryFcn = ( value: any, index: number, next: Callback ) => void;
119118
* @param collection - input collection
120119
* @param next - a callback to be invoked after processing a collection `value`
121120
*/
122-
type QuaternaryFcn = ( value: any, index: number, collection: Collection, next: Callback ) => void; // tslint-disable-line max-line-length
121+
type QuaternaryFcn<T, U, V> = ( this: V, value: T, index: number, collection: Collection<U>, next: Next<U> ) => void;
123122

124123
/**
125124
* Function invoked for each element in a collection.
@@ -129,15 +128,15 @@ type QuaternaryFcn = ( value: any, index: number, collection: Collection, next:
129128
* @param collection - input collection
130129
* @param next - a callback to be invoked after processing a collection `value`
131130
*/
132-
type Fcn = BinaryFcn | TernaryFcn | QuaternaryFcn;
131+
type Fcn<T, U, V> = BinaryFcn<T, U, V> | TernaryFcn<T, U, V> | QuaternaryFcn<T, U, V>;
133132

134133
/**
135134
* Invokes the provided function for each element in a collection and updates a collection in-place.
136135
*
137136
* @param collection - input collection
138137
* @param done - function to invoke upon completion
139138
*/
140-
type FactoryFunction = ( collection: Collection, done: DoneCallback ) => void;
139+
type FactoryFunction<T, U> = ( collection: Collection<T>, done: Callback<U> ) => void;
141140

142141
/**
143142
* Interface for `inmapRightAsync`.
@@ -151,7 +150,6 @@ interface InMapRightAsync {
151150
* - 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. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
152151
* - 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`).
153152
*
154-
*
155153
* @param collection - input collection
156154
* @param options - function options
157155
* @param options.thisArg - execution context
@@ -192,7 +190,7 @@ interface InMapRightAsync {
192190
*
193191
* inmapRightAsync( files, {}, read, done );
194192
*/
195-
( collection: Collection, options: Options, fcn: Fcn, done: DoneCallback ): void; // tslint-disable-line max-line-length
193+
<T = unknown, U = unknown, V = unknown>( collection: Collection<T>, options: Options<T, U, V>, fcn: Fcn<T, U, V>, done: Callback<U> ): void;
196194

197195
/**
198196
* Invokes a function once for each element in a collection and updates a collection in-place.
@@ -202,7 +200,6 @@ interface InMapRightAsync {
202200
* - 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. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
203201
* - 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`).
204202
*
205-
*
206203
* @param collection - input collection
207204
* @param fcn - function to invoke for each element in a collection
208205
* @param done - function to invoke upon completion
@@ -238,7 +235,7 @@ interface InMapRightAsync {
238235
*
239236
* inmapRightAsync( files, read, done );
240237
*/
241-
( collection: Collection, fcn: Fcn, done: DoneCallback ): void;
238+
<T = unknown, U = unknown, V = unknown>( collection: Collection<T>, fcn: Fcn<T, U, V>, done: Callback<U> ): void; // tslint:disable-line:no-unnecessary-generics
242239

243240
/**
244241
* Returns a function to invoke a function once for each element in a collection and to update the collection in-place.
@@ -248,7 +245,6 @@ interface InMapRightAsync {
248245
* - 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. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
249246
* - 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`).
250247
*
251-
*
252248
* @param options - function options
253249
* @param options.thisArg - execution context
254250
* @param options.limit - maximum number of pending invocations at any one time
@@ -298,7 +294,7 @@ interface InMapRightAsync {
298294
* // Run `read` for each element in `files`:
299295
* inmapRightAsync( files, done );
300296
*/
301-
factory( options: Options, fcn: Fcn ): FactoryFunction;
297+
factory<T = unknown, U = unknown, V = unknown>( options: Options<T, U, V>, fcn: Fcn<T, U, V> ): FactoryFunction<T, U>;
302298

303299
/**
304300
* Returns a function to invoke a function once for each element in a collection and to update the collection in-place.
@@ -308,7 +304,6 @@ interface InMapRightAsync {
308304
* - 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. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
309305
* - 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`).
310306
*
311-
*
312307
* @param fcn - function to invoke for each element in a collection
313308
* @throws must provide valid options
314309
* @returns function which invokes the provided function once for each element in a collection
@@ -350,7 +345,7 @@ interface InMapRightAsync {
350345
* // Run `read` for each element in `files`:
351346
* inmapRightAsync( files, done );
352347
*/
353-
factory( fcn: Fcn ): FactoryFunction;
348+
factory<T = unknown, U = unknown, V = unknown>( fcn: Fcn<T, U, V> ): FactoryFunction<T, U>; // tslint:disable-line:no-unnecessary-generics
354349
}
355350

356351
/**
@@ -361,7 +356,6 @@ interface InMapRightAsync {
361356
* - 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. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
362357
* - 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`).
363358
*
364-
*
365359
* @param collection - input collection
366360
* @param options - function options
367361
* @param options.thisArg - execution context

docs/types/test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ const done = ( error: Error | null ) => {
7676

7777
// Attached to main export is a `factory` method which returns a function...
7878
{
79-
inmapRightAsync.factory( fcn ); // $ExpectType FactoryFunction
80-
inmapRightAsync.factory( { 'series': true }, fcn ); // $ExpectType FactoryFunction
79+
inmapRightAsync.factory( fcn ); // $ExpectType FactoryFunction<number, unknown>
80+
inmapRightAsync.factory( { 'series': true }, fcn ); // $ExpectType FactoryFunction<number, unknown>
8181
}
8282

8383
// The compiler throws an error if the `factory` method is provided an options argument which is not an object...

0 commit comments

Comments
 (0)