Skip to content

Commit

Permalink
Release v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Sep 23, 2023
1 parent 056fb8a commit 0c0d330
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 63 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
15 changes: 13 additions & 2 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>

# doUntilEach

[![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 @@ -333,8 +344,8 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
[npm-image]: http://img.shields.io/npm/v/@stdlib/utils-do-until-each.svg
[npm-url]: https://npmjs.org/package/@stdlib/utils-do-until-each

[test-image]: https://github.com/stdlib-js/utils-do-until-each/actions/workflows/test.yml/badge.svg?branch=main
[test-url]: https://github.com/stdlib-js/utils-do-until-each/actions/workflows/test.yml?query=branch:main
[test-image]: https://github.com/stdlib-js/utils-do-until-each/actions/workflows/test.yml/badge.svg?branch=v0.1.0
[test-url]: https://github.com/stdlib-js/utils-do-until-each/actions/workflows/test.yml?query=branch:v0.1.0

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-do-until-each/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/utils-do-until-each?branch=main
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 doUntilEach from '../docs/types/index';
export = doUntilEach;
5 changes: 5 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

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

25 changes: 12 additions & 13 deletions docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* limitations under the License.
*/

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

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

import { Collection } from '@stdlib/types/object';
import { Collection } from '@stdlib/types/array';

/**
* Checks whether an element in a collection passes a test.
Expand All @@ -35,7 +35,7 @@ type NullaryPredicate = () => boolean;
* @param value - collection value
* @returns boolean indicating whether an element in a collection passes a test
*/
type UnaryPredicate = ( value: any ) => boolean;
type UnaryPredicate<T> = ( value: T ) => boolean;

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

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

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

/**
* Function invoked for each collection element until a test condition is true.
*/
type Nullary = () => void;
type Nullary<U> = ( this: U ) => void;

/**
* Function invoked for each collection element until a test condition is true.
*
* @param value - collection value
*/
type Unary = ( value: any ) => void;
type Unary<T, U> = ( this: U, value: T ) => void;

/**
* Function invoked for each collection element until a test condition is true.
*
* @param value - collection value
* @param index - collection index
*/
type Binary = ( value: any, index: number ) => void;
type Binary<T, U> = ( this: U, value: T, index: number ) => void;

/**
* Function invoked for each collection element until a test condition is true.
Expand All @@ -93,7 +93,7 @@ type Binary = ( value: any, index: number ) => void;
* @param index - collection index
* @param collection - input collection
*/
type Ternary = ( value: any, index: number, collection: Collection ) => void;
type Ternary<T, U> = ( this: U, value: T, index: number, collection: Collection<T> ) => void;

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

/**
* Until a test condition is true, invokes a function once for each element in a collection.
Expand All @@ -119,7 +119,6 @@ type Callback = Nullary | Unary | Binary | Ternary;
*
* - If provided an empty collection, the function invokes the provided function with the collection index set to `undefined`.
*
*
* @param collection - input collection
* @param fcn - function to invoke
* @param predicate - function which indicates whether to stop iterating over a collection
Expand All @@ -139,7 +138,7 @@ type Callback = Nullary | Unary | Binary | Ternary;
*
* doUntilEach( arr, log, predicate );
*/
declare function doUntilEach( collection: Collection, fcn: Callback, predicate: Predicate, thisArg?: any ): Collection; // tslint-disable-line max-line-length
declare function doUntilEach<T = unknown, U = unknown>( collection: Collection<T>, fcn: Callback<T, U>, predicate: Predicate<T>, thisArg?: ThisParameterType<Callback<T, U>> ): Collection<T>;


// EXPORTS //
Expand Down
48 changes: 29 additions & 19 deletions docs/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,38 @@

import doUntilEach = require( './index' );

const log = ( v: any, index: number ): void => {
console.log( `${index}: ${v}` );
};
/**
* Dummy function.
*/
function fcn( v: any, index: number ): number {
if ( v !== v ) {
throw new Error( 'beep' );
}
return index;
}

const isNotNaN = ( v: number ): boolean => {
/**
* Dummy function.
*/
function isNotNaN( v: number ): boolean {
return ( v === v );
};
}


// TESTS //

// The function returns the input collection...
{
doUntilEach( [ 0, 1, 1, NaN, 2 ], log, isNotNaN ); // $ExpectType Collection
doUntilEach( [ -1, 1, 2 ], log, isNotNaN, {} ); // $ExpectType Collection
doUntilEach( [ 0, 1, 1, NaN, 2 ], fcn, isNotNaN ); // $ExpectType Collection<number>
doUntilEach( [ -1, 1, 2 ], fcn, isNotNaN, {} ); // $ExpectType Collection<number>
}

// The compiler throws an error if the function is provided a first argument which is not a collection...
{
doUntilEach( 2, log, isNotNaN ); // $ExpectError
doUntilEach( false, log, isNotNaN ); // $ExpectError
doUntilEach( true, log, isNotNaN ); // $ExpectError
doUntilEach( {}, log, isNotNaN ); // $ExpectError
doUntilEach( 2, fcn, isNotNaN ); // $ExpectError
doUntilEach( false, fcn, isNotNaN ); // $ExpectError
doUntilEach( true, fcn, isNotNaN ); // $ExpectError
doUntilEach( {}, fcn, isNotNaN ); // $ExpectError
}

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

// The compiler throws an error if the function is provided a third argument which is not a function...
{
doUntilEach( [ 0, 1, 1, NaN, 2 ], log, 2 ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], log, false ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], log, true ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], log, 'abc' ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], log, {} ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], log, [] ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], fcn, 2 ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], fcn, false ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], fcn, true ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], fcn, 'abc' ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], fcn, {} ); // $ExpectError
doUntilEach( [ 0, 1, 1, NaN, 2 ], fcn, [] ); // $ExpectError
}

// The compiler throws an error if the function is provided an invalid number of arguments...
{
doUntilEach(); // $ExpectError
doUntilEach( [ 1, 2, 3 ] ); // $ExpectError
doUntilEach( [ 1, 2, 3 ], log ); // $ExpectError
doUntilEach( [ 1, 2, 3 ], log, isNotNaN, {}, 3 ); // $ExpectError
doUntilEach( [ 1, 2, 3 ], fcn ); // $ExpectError
doUntilEach( [ 1, 2, 3 ], fcn, isNotNaN, {}, 3 ); // $ExpectError
}
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stdlib/utils-do-until-each",
"version": "0.0.8",
"version": "0.1.0",
"description": "Until a test condition is true, invoke a function for each element in a collection.",
"license": "Apache-2.0",
"author": {
Expand Down Expand Up @@ -37,22 +37,22 @@
"url": "https://github.com/stdlib-js/stdlib/issues"
},
"dependencies": {
"@stdlib/assert-is-collection": "^0.0.8",
"@stdlib/assert-is-function": "^0.0.8",
"@stdlib/string-format": "^0.0.3",
"@stdlib/types": "^0.0.14"
"@stdlib/assert-is-collection": "^0.1.0",
"@stdlib/assert-is-function": "^0.1.0",
"@stdlib/string-format": "^0.1.0",
"@stdlib/types": "^0.1.0"
},
"devDependencies": {
"@stdlib/array-float32": "^0.0.6",
"@stdlib/array-float64": "^0.0.6",
"@stdlib/assert-is-even": "^0.0.8",
"@stdlib/assert-is-nan": "^0.0.8",
"@stdlib/bench": "^0.0.12",
"@stdlib/constants-float64-pinf": "^0.0.8",
"@stdlib/math-base-assert-is-nan": "^0.0.8",
"@stdlib/math-base-special-floor": "^0.0.8",
"@stdlib/array-float32": "^0.1.0",
"@stdlib/array-float64": "^0.1.0",
"@stdlib/assert-is-even": "^0.1.0",
"@stdlib/assert-is-nan": "^0.1.0",
"@stdlib/bench": "^0.1.0",
"@stdlib/constants-float64-pinf": "^0.1.0",
"@stdlib/math-base-assert-is-nan": "^0.1.0",
"@stdlib/math-base-special-floor": "^0.1.0",
"@stdlib/random-base-randu": "^0.0.8",
"@stdlib/utils-noop": "^0.0.14",
"@stdlib/utils-noop": "^0.1.0",
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
"istanbul": "^0.4.1",
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
Expand Down

0 comments on commit 0c0d330

Please sign in to comment.