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 3c46abc commit 5381342
Show file tree
Hide file tree
Showing 338 changed files with 2,622 additions and 1,969 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
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
11 changes: 11 additions & 0 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>

# Utils

[![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
14 changes: 7 additions & 7 deletions any-by-right/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

// TypeScript Version: 2.0
// TypeScript Version: 4.1

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

Expand All @@ -27,15 +27,15 @@ import { Collection } from '@stdlib/types/array';
*
* @returns boolean indicating whether an element in a collection passes a test
*/
type Nullary = () => boolean;
type Nullary<U> = ( this: U ) => boolean;

/**
* Checks whether an element in a collection passes a test.
*
* @param value - collection value
* @returns boolean indicating whether an element in a collection passes a test
*/
type Unary<T> = ( value: T ) => boolean;
type Unary<T, U> = ( this: U, value: T ) => boolean;

/**
* Checks whether an element in a collection passes a test.
Expand All @@ -44,7 +44,7 @@ type Unary<T> = ( value: T ) => boolean;
* @param index - collection index
* @returns boolean indicating whether an element in a collection passes a test
*/
type Binary<T> = ( value: T, index: number ) => boolean;
type Binary<T, U> = ( this: U, value: T, index: number ) => boolean;

/**
* Checks whether an element in a collection passes a test.
Expand All @@ -54,7 +54,7 @@ type Binary<T> = ( value: T, index: number ) => boolean;
* @param collection - input collection
* @returns boolean indicating whether an element in a collection passes a test
*/
type Ternary<T> = ( value: T, index: number, collection: Collection<T> ) => boolean;
type Ternary<T, U> = ( this: U, value: T, index: number, collection: Collection<T> ) => boolean;

/**
* Checks whether an element in a collection passes a test.
Expand All @@ -64,7 +64,7 @@ type Ternary<T> = ( value: T, index: number, collection: Collection<T> ) => bool
* @param collection - input collection
* @returns boolean indicating whether an element in a collection passes a test
*/
type Predicate<T> = Nullary | Unary<T> | Binary<T> | Ternary<T>;
type Predicate<T, U> = Nullary<U> | Unary<T, U> | Binary<T, U> | Ternary<T, U>;

/**
* Tests whether at least one element in a collection passes a test implemented by a predicate function.
Expand Down Expand Up @@ -96,7 +96,7 @@ type Predicate<T> = Nullary | Unary<T> | Binary<T> | Ternary<T>;
* var bool = anyByRight( arr, isNegative );
* // returns true
*/
declare function anyByRight<T = unknown>( collection: Collection<T>, predicate: Predicate<T>, thisArg?: ThisParameterType<Predicate<T>> ): boolean;
declare function anyByRight<T = unknown, U = unknown>( collection: Collection<T>, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolean;


// EXPORTS //
Expand Down
14 changes: 7 additions & 7 deletions any-by/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

// TypeScript Version: 2.0
// TypeScript Version: 4.1

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

Expand All @@ -27,15 +27,15 @@ import { Collection } from '@stdlib/types/array';
*
* @returns boolean indicating whether an element in a collection passes a test
*/
type Nullary = () => boolean;
type Nullary<U> = ( this: U ) => boolean;

/**
* Checks whether an element in a collection passes a test.
*
* @param value - collection value
* @returns boolean indicating whether an element in a collection passes a test
*/
type Unary<T> = ( value: T ) => boolean;
type Unary<T, U> = ( this: U, value: T ) => boolean;

/**
* Checks whether an element in a collection passes a test.
Expand All @@ -44,7 +44,7 @@ type Unary<T> = ( value: T ) => boolean;
* @param index - collection index
* @returns boolean indicating whether an element in a collection passes a test
*/
type Binary<T> = ( value: T, index: number ) => boolean;
type Binary<T, U> = ( this: U, value: T, index: number ) => boolean;

/**
* Checks whether an element in a collection passes a test.
Expand All @@ -54,7 +54,7 @@ type Binary<T> = ( value: T, index: number ) => boolean;
* @param collection - input collection
* @returns boolean indicating whether an element in a collection passes a test
*/
type Ternary<T> = ( value: T, index: number, collection: Collection<T> ) => boolean;
type Ternary<T, U> = ( this: U, value: T, index: number, collection: Collection<T> ) => boolean;

/**
* Checks whether an element in a collection passes a test.
Expand All @@ -64,7 +64,7 @@ type Ternary<T> = ( value: T, index: number, collection: Collection<T> ) => bool
* @param collection - input collection
* @returns boolean indicating whether an element in a collection passes a test
*/
type Predicate<T> = Nullary | Unary<T> | Binary<T> | Ternary<T>;
type Predicate<T, U> = Nullary<U> | Unary<T, U> | Binary<T, U> | Ternary<T, U>;

/**
* Tests whether at least one element in a collection passes a test implemented by a predicate function, iterating from right to left.
Expand Down Expand Up @@ -96,7 +96,7 @@ type Predicate<T> = Nullary | Unary<T> | Binary<T> | Ternary<T>;
* var bool = anyBy( arr, isNegative );
* // returns true
*/
declare function anyBy<T = unknown>( collection: Collection<T>, predicate: Predicate<T>, thisArg?: ThisParameterType<Predicate<T>> ): boolean;
declare function anyBy<T = unknown, U = unknown>( collection: Collection<T>, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolean;


// EXPORTS //
Expand Down
2 changes: 1 addition & 1 deletion append/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

// TypeScript Version: 2.0
// TypeScript Version: 4.1

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

Expand Down
2 changes: 1 addition & 1 deletion argument-function/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

// TypeScript Version: 2.0
// TypeScript Version: 4.1

/**
* Returns a function which always returns a specified argument.
Expand Down
67 changes: 36 additions & 31 deletions async/any-by-right/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ function predicate( value, next ) {
setTimeout( onTimeout, value );
function onTimeout() {
console.log( value );
/* =>
1000
2500
3000
*/

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

var arr = [ 1000, 2500, 3000 ];

anyByRightAsync( 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 @@ -89,19 +90,19 @@ function done( error, bool ) {
throw error;
}
console.log( bool );
// => true
}

var arr = [ 1000, 2500, 3000 ];

anyByRightAsync( 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 @@ -110,6 +111,11 @@ function predicate( value, next ) {
setTimeout( onTimeout, value );
function onTimeout() {
console.log( value );
/* =>
3000
2500
1000
*/
next( null, false );
}
}
Expand All @@ -119,6 +125,7 @@ function done( error, bool ) {
throw error;
}
console.log( bool );
// => false
}

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

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

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

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

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

anyByRightAsync( 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 @@ -216,9 +218,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. 2: 3000
collection: 3000,2500,1000. 1: 2500
collection: 3000,2500,1000. 0: 1000
*/
setTimeout( onTimeout, value );
function onTimeout() {
console.log( value );
/* =>
1000
2500
3000
*/

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

var arr = [ 1000, 2500, 3000 ];

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

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

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

f( arr2, done );
/* =>
/* e.g., =>
100
250
300
Expand Down
Loading

0 comments on commit 5381342

Please sign in to comment.