Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Sep 20, 2023
1 parent 042958c commit b6b6bf2
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 66 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,8 @@ indent_size = 2
[*.gypi]
indent_style = space
indent_size = 2

# Set properties for citation files:
[*.{cff,cff.txt}]
indent_style = space
indent_size = 2
15 changes: 0 additions & 15 deletions .github/workflows/productionize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,6 @@ jobs:
id: transform-error-messages
uses: stdlib-js/transform-errors-action@main

# Format error messages:
- name: 'Replace double quotes with single quotes in rewritten format string error messages'
run: |
find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \;
# Format string literal error messages:
- name: 'Replace double quotes with single quotes in rewritten string literal error messages'
run: |
find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \;
# Format code:
- name: 'Replace double quotes with single quotes in inserted `require` calls'
run: |
find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \;
# Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency:
- name: 'Update dependencies in package.json'
run: |
Expand Down
30 changes: 30 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cff-version: 1.2.0
title: stdlib
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software

authors:
- name: The Stdlib Authors
url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
Standard library for JavaScript and Node.js.
keywords:
- JavaScript
- Node.js
- TypeScript
- standard library
- scientific computing
- numerical computing
- statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016
79 changes: 48 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ limitations under the License.
-->


<details>
<summary>
About stdlib...
</summary>
<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>
<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>
<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>
<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>
</details>

# anyByAsync

[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
Expand Down Expand Up @@ -69,6 +80,12 @@ function predicate( value, next ) {
setTimeout( onTimeout, value );
function onTimeout() {
console.log( value );
/* =>
1000
2500
3000
*/

next( null, false );
}
}
Expand All @@ -78,17 +95,12 @@ function done( error, bool ) {
throw error;
}
console.log( bool );
// => false
}

var arr = [ 3000, 2500, 1000 ];

anyByAsync( arr, predicate, done );
/* =>
1000
2500
3000
false
*/
```

If a `predicate` function calls the `next` callback with a truthy test argument, the function stops processing any additional `collection` elements and returns `true` for the test result.
Expand All @@ -109,19 +121,19 @@ function done( error, bool ) {
throw error;
}
console.log( bool );
// => true
}

var arr = [ 3000, 2500, 1000 ];

anyByAsync( arr, predicate, done );
// => true
```

The function accepts the following `options`:

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

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

Expand All @@ -130,6 +142,12 @@ function predicate( value, next ) {
setTimeout( onTimeout, value );
function onTimeout() {
console.log( value );
/* =>
3000
2500
1000
*/

next( null, false );
}
}
Expand All @@ -139,6 +157,7 @@ function done( error, bool ) {
throw error;
}
console.log( bool );
// => false
}

var arr = [ 3000, 2500, 1000 ];
Expand All @@ -148,12 +167,6 @@ var opts = {
};

anyByAsync( arr, opts, predicate, done );
/* =>
3000
2500
1000
false
*/
```

To limit the maximum number of pending function invocations, set the `limit` option.
Expand All @@ -163,6 +176,12 @@ function predicate( value, next ) {
setTimeout( onTimeout, value );
function onTimeout() {
console.log( value );
/* =>
2500
3000
1000
*/

next( null, false );
}
}
Expand All @@ -172,6 +191,7 @@ function done( error, bool ) {
throw error;
}
console.log( bool );
// => false
}

var arr = [ 3000, 2500, 1000 ];
Expand All @@ -181,12 +201,6 @@ var opts = {
};

anyByAsync( arr, opts, predicate, done );
/* =>
2500
3000
1000
false
*/
```

To set the execution context of the `predicate` function, set the `thisArg` option.
Expand Down Expand Up @@ -236,9 +250,20 @@ The actual number of provided arguments depends on function `length`. If the `pr
```javascript
function predicate( value, i, collection, next ) {
console.log( 'collection: %s. %d: %d', collection.join( ',' ), i, value );
/* =>
collection: 3000,2500,1000. 0: 3000
collection: 3000,2500,1000. 1: 2500
collection: 3000,2500,1000. 2: 1000
*/
setTimeout( onTimeout, value );
function onTimeout() {
console.log( value );
/* =>
1000
2500
3000
*/

next( null, false );
}
}
Expand All @@ -248,20 +273,12 @@ function done( error, bool ) {
throw error;
}
console.log( bool );
// => false
}

var arr = [ 3000, 2500, 1000 ];

anyByAsync( arr, predicate, done );
/* =>
collection: 3000,2500,1000. 0: 3000
collection: 3000,2500,1000. 1: 2500
collection: 3000,2500,1000. 2: 1000
1000
2500
3000
false
*/
```

#### anyByAsync.factory( \[options,] predicate )
Expand Down Expand Up @@ -289,7 +306,7 @@ var f = anyByAsync.factory( predicate );
var arr1 = [ 3000, 2500, 1000 ];

f( arr1, done );
/* =>
/* e.g., =>
1000
2500
3000
Expand All @@ -299,7 +316,7 @@ f( arr1, done );
var arr2 = [ 300, 250, 100 ];

f( arr2, done );
/* =>
/* e.g., =>
100
250
300
Expand Down
3 changes: 3 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference path="../docs/types/index.d.ts" />
import anyByAsync from '../docs/types/index';
export = anyByAsync;
11 changes: 11 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit b6b6bf2

Please sign in to comment.