From 3f0cadfb868176e7d6ae21db20216e5b59c5c5bb Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 13 Oct 2022 01:11:16 -0400 Subject: [PATCH 01/24] Add README.md --- .../@stdlib/utils/delay/README.md | 192 ++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 lib/node_modules/@stdlib/utils/delay/README.md diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md new file mode 100644 index 000000000000..325fb61b54df --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -0,0 +1,192 @@ + + +# delay + +> Invoke a function after a specified number of milliseconds. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var delay = require( '@stdlib/utils/delay' ); +``` + +#### delay( fcn, wait\[, ...args] ) + +Invokes a function after a specified number of milliseconds. + +```javascript +function beep() { + console.log( 'beep' ); +} + +delay( beep, 3000 ); +// Logs 'beep' after three seconds... +``` + +The function accepts additional arguments to invoke the function with. + +```javascript +function add( x, y ) { + var sum = x + y; + console.log( 'sum: %d', sum ); +} + +delay( add, 3000, 2, 3 ); +// Logs 'sum: 5' after three seconds... +``` + +The function returns a `timeout` object with the following properties and methods: + +#### timeout.clear() + +Clears a pending invocation of a function. + +```javascript +function beep() { + console.log( 'beep' ); +} +var t = delay( beep, 3000 ); +t.clear(); +``` + +#### timeout.duration + +Timeout duration (in milliseconds) before invoking a function. + +```javascript +function beep() { + console.log( 'beep' ); +} +var t = delay( beep, 3000 ); +var duration = t.duration; +// returns 3000 +``` + +#### timeout.status + +Integer indicating the status of a timeout. The following values are possible: + +- `0`: fuction has not yet been invoked. +- `1`: function has been invoked. +- `2`: function invocation has been cleared. + +```javascript +function beep() { + console.log( 'beep' ); +} +var t = delay( beep, 3000 ); +var status = t.status; +// returns 0 + +t.clear(); +status = t.status; +// returns 2 +``` + +
+ + + + + +
+ +## Notes + +- The function accepts additional arguments to invoke the function with. These arguments are provided to the supplied function in the same order as provided to the `delay` function. + +
+ + + + + +
+ +## Examples + + + +```javascript +var delay = require( '@stdlib/utils/delay' ); + +function beep() { + console.log( 'beep' ); +} +function boop() { + console.log( 'boop' ); +} +function baz() { + console.log( 'baz' ); +} + +var t1 = delay( beep, 3000 ); +var t2 = delay( boop, 1000 ); +var t3 = delay( baz, 4000 ); + +t1.clear(); + +// Wait 3 seconds... +// => beep + +// Wait 1 more second... +// => baz +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + From 04655c8bed3e8123142bd6c55fe5cc2816427749 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 13 Oct 2022 01:16:47 -0400 Subject: [PATCH 02/24] Add method and note --- lib/node_modules/@stdlib/utils/delay/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 325fb61b54df..b77114fe037d 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -79,6 +79,19 @@ var t = delay( beep, 3000 ); t.clear(); ``` +#### timeout.invoke() + +Invokes a function immediately. + +```javascript +function beep() { + console.log( 'beep' ); +} +var t = delay( beep, 3000 ); +t.invoke(); +// Logs 'beep' immediately... +``` + #### timeout.duration Timeout duration (in milliseconds) before invoking a function. @@ -124,6 +137,7 @@ status = t.status; ## Notes - The function accepts additional arguments to invoke the function with. These arguments are provided to the supplied function in the same order as provided to the `delay` function. +- In contrast to using `setTimeout`, which returns a timeout identifier that can be used to clear a pending invocation by calling `clearTimeout`, the `delay` function returns a `timeout` object with additional properties and methods. From 87112d689c7a42edc3c7435e5c6bb407eca3f2f3 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 13 Oct 2022 01:11:16 -0400 Subject: [PATCH 03/24] Add README.md --- .../@stdlib/utils/delay/README.md | 192 ++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 lib/node_modules/@stdlib/utils/delay/README.md diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md new file mode 100644 index 000000000000..325fb61b54df --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -0,0 +1,192 @@ + + +# delay + +> Invoke a function after a specified number of milliseconds. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var delay = require( '@stdlib/utils/delay' ); +``` + +#### delay( fcn, wait\[, ...args] ) + +Invokes a function after a specified number of milliseconds. + +```javascript +function beep() { + console.log( 'beep' ); +} + +delay( beep, 3000 ); +// Logs 'beep' after three seconds... +``` + +The function accepts additional arguments to invoke the function with. + +```javascript +function add( x, y ) { + var sum = x + y; + console.log( 'sum: %d', sum ); +} + +delay( add, 3000, 2, 3 ); +// Logs 'sum: 5' after three seconds... +``` + +The function returns a `timeout` object with the following properties and methods: + +#### timeout.clear() + +Clears a pending invocation of a function. + +```javascript +function beep() { + console.log( 'beep' ); +} +var t = delay( beep, 3000 ); +t.clear(); +``` + +#### timeout.duration + +Timeout duration (in milliseconds) before invoking a function. + +```javascript +function beep() { + console.log( 'beep' ); +} +var t = delay( beep, 3000 ); +var duration = t.duration; +// returns 3000 +``` + +#### timeout.status + +Integer indicating the status of a timeout. The following values are possible: + +- `0`: fuction has not yet been invoked. +- `1`: function has been invoked. +- `2`: function invocation has been cleared. + +```javascript +function beep() { + console.log( 'beep' ); +} +var t = delay( beep, 3000 ); +var status = t.status; +// returns 0 + +t.clear(); +status = t.status; +// returns 2 +``` + +
+ + + + + +
+ +## Notes + +- The function accepts additional arguments to invoke the function with. These arguments are provided to the supplied function in the same order as provided to the `delay` function. + +
+ + + + + +
+ +## Examples + + + +```javascript +var delay = require( '@stdlib/utils/delay' ); + +function beep() { + console.log( 'beep' ); +} +function boop() { + console.log( 'boop' ); +} +function baz() { + console.log( 'baz' ); +} + +var t1 = delay( beep, 3000 ); +var t2 = delay( boop, 1000 ); +var t3 = delay( baz, 4000 ); + +t1.clear(); + +// Wait 3 seconds... +// => beep + +// Wait 1 more second... +// => baz +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + From 144f3ac8c083c58b5630316d2dff4652b506f391 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 13 Oct 2022 01:16:47 -0400 Subject: [PATCH 04/24] Add method and note --- lib/node_modules/@stdlib/utils/delay/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 325fb61b54df..b77114fe037d 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -79,6 +79,19 @@ var t = delay( beep, 3000 ); t.clear(); ``` +#### timeout.invoke() + +Invokes a function immediately. + +```javascript +function beep() { + console.log( 'beep' ); +} +var t = delay( beep, 3000 ); +t.invoke(); +// Logs 'beep' immediately... +``` + #### timeout.duration Timeout duration (in milliseconds) before invoking a function. @@ -124,6 +137,7 @@ status = t.status; ## Notes - The function accepts additional arguments to invoke the function with. These arguments are provided to the supplied function in the same order as provided to the `delay` function. +- In contrast to using `setTimeout`, which returns a timeout identifier that can be used to clear a pending invocation by calling `clearTimeout`, the `delay` function returns a `timeout` object with additional properties and methods. From fe146fb9ae823da2d2938ce058e87a9a128f61df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 13 Oct 2022 05:36:22 +0000 Subject: [PATCH 05/24] Scaffold utils/delay package files --- .../utils/delay/benchmark/benchmark.js | 54 ++++++ .../@stdlib/utils/delay/docs/repl.txt | 37 +++++ .../@stdlib/utils/delay/docs/types/index.d.ts | 55 ++++++ .../@stdlib/utils/delay/docs/types/test.ts | 58 +++++++ .../@stdlib/utils/delay/examples/index.js | 43 +++++ .../@stdlib/utils/delay/lib/index.js | 45 +++++ .../@stdlib/utils/delay/lib/main.js | 64 +++++++ .../@stdlib/utils/delay/package.json | 52 ++++++ .../@stdlib/utils/delay/test/test.js | 156 ++++++++++++++++++ 9 files changed, 564 insertions(+) create mode 100644 lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/utils/delay/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/utils/delay/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/utils/delay/examples/index.js create mode 100644 lib/node_modules/@stdlib/utils/delay/lib/index.js create mode 100644 lib/node_modules/@stdlib/utils/delay/lib/main.js create mode 100644 lib/node_modules/@stdlib/utils/delay/package.json create mode 100644 lib/node_modules/@stdlib/utils/delay/test/test.js diff --git a/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js new file mode 100644 index 000000000000..c52536fcf313 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var delay = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var fn; + var t; + var i; + + fn = function beep() { + console.log( 'beep' ); + }; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + t = delay( fn, 1000 ); + if ( typeof t.status !== 'number' ) { + b.fail( 'should return a timeout object' ); + } + } + b.toc(); + if ( !isBoolean( t.status ) ) { + b.fail( 'should return a timeout object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + diff --git a/lib/node_modules/@stdlib/utils/delay/docs/repl.txt b/lib/node_modules/@stdlib/utils/delay/docs/repl.txt new file mode 100644 index 000000000000..49f65b228025 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/docs/repl.txt @@ -0,0 +1,37 @@ + +{{alias}}( fcn, wait[, ...args] ) + Invokes a function after a specified number of milliseconds. + + Parameters + ---------- + fcn: Function + Function to invoke. + + wait: integer + Milliseconds to wait before invoking a function. + + args: ...any + Additional arguments to invoke the function with. + + Returns + ------- + out: Object + Function invocation timeout object. + + Examples + -------- + > function beep() { console.log( 'beep' ); }; + > {{alias}}( beep, 3000 ) + + > var t = {{alias}}( beep, 3000 ) + + > t.clear() + > t.invoke() + beep + > t.duration + 3000 + > t.status + 0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts new file mode 100644 index 000000000000..c8922d410c7f --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +/** +* Invokes a function after a specified number of milliseconds. +* +* @private +* @param fcn - function to invoke +* @param wait - wait duration (in milliseconds) +* @param args - arguments to invoke `fcn` with +* @returns timeout object +* +* @example +* function beep() { +* console.log( 'beep' ); +* } +* +* var t = delay( beep, 3000 ); +* +* var status = t.status; +* // returns 0 +* +* t.clear(); +* +* status = t.status; +* // returns 2 +* +* t.invoke(); +* +* var duration = t.duration; +* // returns 3000 +*/ +declare function delay( fcn: Function, wait: number, ...args: Array ): TimeoutObject; // tslint-disable-line max-line-length + +// EXPORTS // + +export = delay; + diff --git a/lib/node_modules/@stdlib/utils/delay/docs/types/test.ts b/lib/node_modules/@stdlib/utils/delay/docs/types/test.ts new file mode 100644 index 000000000000..eea1f6b9b179 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/docs/types/test.ts @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import delay = require( './index' ); + + +// TESTS // + +// The function returns a timeout object... +{ + delay( () => {}, 2000 ); // $ExpectType TimeoutObject +} + +// The compiler throws an error if the function is provided a first argument which is not a function... +{ + delay( 'beep', 2000 ); // $ExpectError + delay( 5, 2000 ); // $ExpectError + delay( true, 2000 ); // $ExpectError + delay( false, 2000 ); // $ExpectError + delay( null, 2000 ); // $ExpectError + + delay( [], 2000 ); // $ExpectError + delay( {}, 2000 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + delay( () => {}, 'beep' ); // $ExpectError + delay( () => {}, true ); // $ExpectError + delay( () => {}, false ); // $ExpectError + delay( () => {}, null ); // $ExpectError + delay( () => {}, [] ); // $ExpectError + delay( () => {}, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an incorrect number of arguments... +{ + delay(); // $ExpectError + delay( () => {} ); // $ExpectError + delay( () => {}, 2000, 'beep' ); // $ExpectError +} + + diff --git a/lib/node_modules/@stdlib/utils/delay/examples/index.js b/lib/node_modules/@stdlib/utils/delay/examples/index.js new file mode 100644 index 000000000000..dfa820d761f8 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var delay = require( './../lib' ); + +function beep() { + console.log( 'beep' ); +} +function boop() { + console.log( 'boop' ); +} +function baz() { + console.log( 'baz' ); +} + +var t1 = delay( beep, 3000 ); +var t2 = delay( boop, 1000 ); +var t3 = delay( baz, 4000 ); + +t1.clear(); + +// Wait 3 seconds... +// => beep + +// Wait 1 more second... +// => baz diff --git a/lib/node_modules/@stdlib/utils/delay/lib/index.js b/lib/node_modules/@stdlib/utils/delay/lib/index.js new file mode 100644 index 000000000000..6788fe2ec0b5 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/lib/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + + +/** +* Invoke a function after a specified number of milliseconds. +* +* @module @stdlib/utils/delay +* +* @example +* var delay = require( '@stdlib/utils/delay' ); +* +* function beep() { +* console.log( 'beep' ); +* } +* +* delay( beep, 3000 ); +* // Logs 'beep' after three seconds... +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/utils/delay/lib/main.js b/lib/node_modules/@stdlib/utils/delay/lib/main.js new file mode 100644 index 000000000000..32de4b832f95 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/lib/main.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +// TODO: Load required modules... + + +// MAIN // + +/** +* Invokes a function after a specified number of milliseconds. +* +* @private +* @param {Function} fcn - function to invoke +* @param {NonNegativeInteger} wait - wait duration (in milliseconds) +* @param {...*} [args] - arguments to invoke `fcn` with +* @returns {TimeoutObject} timeout object +* +* @example +* function beep() { +* console.log( 'beep' ); +* } +* +* var t = delay( beep, 3000 ); +* +* var status = t.status; +* // returns 0 +* +* t.clear(); +* +* status = t.status; +* // returns 2 +* +* t.invoke(); +* +* var duration = t.duration; +* // returns 3000 +*/ +function delay( fcn, wait ) { + // TODO: Add implementation... +} + + +// EXPORTS // + +module.exports = delay; diff --git a/lib/node_modules/@stdlib/utils/delay/package.json b/lib/node_modules/@stdlib/utils/delay/package.json new file mode 100644 index 000000000000..5ce9664c2711 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/package.json @@ -0,0 +1,52 @@ +{ + "name": "@stdlib/utils/delay", + "version": "0.0.0", + "description": "", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [] +} diff --git a/lib/node_modules/@stdlib/utils/delay/test/test.js b/lib/node_modules/@stdlib/utils/delay/test/test.js new file mode 100644 index 000000000000..7f4787209235 --- /dev/null +++ b/lib/node_modules/@stdlib/utils/delay/test/test.js @@ -0,0 +1,156 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var delay = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.equal( typeof delay, 'function', 'export is a function' ); + t.end(); +}); + +tape( 'the function delays execution by a specified number of milliseconds', function test( t ) { + var out = false; + var i = setTimeout( onTimeout, 1000 ); + + function onTimeout() { + out = true; + clearTimeout( i ); + t.ok( true ); + t.end(); + } + if ( out ) { + t.ok( false, 'should not be invoked' ); + } +}); + +tape( 'if the function is called with additional arguments, the function is invoked with those arguments', function test( t ) { + var out; + var i = setTimeout( onTimeout, 1000 ); + + function onTimeout( a, b ) { + out = a + b; + clearTimeout( i ); + t.ok( true ); + t.end(); + } + + if ( out ) { + t.ok( false, 'should not be invoked' ); + } +}); + +tape( 'the function returns a timeout object', function test( t ) { + var i = setTimeout( onTimeout, 1000 ); + + function onTimeout() { + clearTimeout( i ); + t.ok( true ); + t.end(); + } +}); + +tape( 'the returned timeout object exposes a `clear` method to clear a pending timeout', function test( t ) { + var out; + var i = setTimeout( onTimeout, 1000 ); + + function onTimeout() { + out = true; + clearTimeout( i ); + t.ok( false, 'should not be invoked' ); + t.end(); + } + + i.clear(); + + if ( out ) { + t.ok( false, 'should not be invoked' ); + } else { + t.ok( true ); + t.end(); + } +}); + +tape( 'the returned timeout object exposes an `invoke` method to invoke a function immediately', function test( t ) { + var out; + var i = setTimeout( onTimeout, 1000 ); + + function onTimeout() { + out = true; + clearTimeout( i ); + t.ok( true ); + t.end(); + } + + i.invoke(); + + if ( out ) { + t.ok( true ); + t.end(); + } else { + t.ok( false, 'should not be invoked' ); + t.end(); + } +}); + +tape( 'the returned timeout object exposes a property for getting the timeout duration (in milliseconds)', function test( t ) { + var i = setTimeout( onTimeout, 1000 ); + + function onTimeout() { + clearTimeout( i ); + t.equal( i.duration, 1000, 'returns duration' ); + t.end(); + } +}); + +tape( 'the returned timeout object exposes a property for getting the timeout status', function test( t ) { + var i = setTimeout( onTimeout, 1000 ); + + function onTimeout() { + clearTimeout( i ); + t.equal( i.status, 1, 'returns status' ); + t.end(); + } +}); + +tape( 'the returned timeout object exposes a property for getting the timeout status', function test( t ) { + var out; + var i = setTimeout( onTimeout, 1000 ); + + function onTimeout() { + out = true; + clearTimeout( i ); + t.ok( false, 'should not be invoked' ); + t.end(); + } + + i.clear(); + if ( out ) { + t.ok( false, 'should not be invoked' ); + t.end(); + } else { + t.equal( i.status, 2, 'returns status' ); + t.end(); From 391fc175cfc4ae8fec17486eb2d332b37fa0eff1 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 14 Oct 2022 18:20:44 -0700 Subject: [PATCH 06/24] Apply suggestions from code review --- .../@stdlib/utils/delay/README.md | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index b77114fe037d..128c9f3d94db 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -20,7 +20,7 @@ limitations under the License. # delay -> Invoke a function after a specified number of milliseconds. +> Invoke a function after a specified duration. @@ -40,20 +40,21 @@ limitations under the License. var delay = require( '@stdlib/utils/delay' ); ``` -#### delay( fcn, wait\[, ...args] ) +#### delay( fcn, duration\[, ...args] ) -Invokes a function after a specified number of milliseconds. +Invokes a function after a specified duration. ```javascript function beep() { console.log( 'beep' ); } -delay( beep, 3000 ); -// Logs 'beep' after three seconds... +// Invoke a function after 3 seconds: +var t = delay( beep, 3000 ); +// returns ``` -The function accepts additional arguments to invoke the function with. +The function supports providing additional arguments to pass through to the delayed function upon invocation. The delayed function receives additional arguments in the same order in which they are provided to `delay`. ```javascript function add( x, y ) { @@ -61,12 +62,11 @@ function add( x, y ) { console.log( 'sum: %d', sum ); } -delay( add, 3000, 2, 3 ); -// Logs 'sum: 5' after three seconds... +var t = delay( add, 3000, 2, 3 ); +// returns ``` -The function returns a `timeout` object with the following properties and methods: - +The function returns a `timeout` object having properties and methods as documented below. #### timeout.clear() Clears a pending invocation of a function. @@ -81,7 +81,7 @@ t.clear(); #### timeout.invoke() -Invokes a function immediately. +Clears a pending invocation and invokes a function immediately. ```javascript function beep() { @@ -89,35 +89,32 @@ function beep() { } var t = delay( beep, 3000 ); t.invoke(); -// Logs 'beep' immediately... ``` #### timeout.duration -Timeout duration (in milliseconds) before invoking a function. +Read-only value specifying the duration (in milliseconds) before invoking a delayed function. ```javascript function beep() { console.log( 'beep' ); } var t = delay( beep, 3000 ); + var duration = t.duration; // returns 3000 ``` #### timeout.status -Integer indicating the status of a timeout. The following values are possible: - -- `0`: fuction has not yet been invoked. -- `1`: function has been invoked. -- `2`: function invocation has been cleared. +Read-only integer value indicating the status of a delayed function. ```javascript function beep() { console.log( 'beep' ); } var t = delay( beep, 3000 ); + var status = t.status; // returns 0 @@ -126,6 +123,11 @@ status = t.status; // returns 2 ``` +A status may be one of the following values: + +- `0`: function invocation is pending. +- `1`: function invocation is complete. +- `2`: function invocation has been cleared. @@ -136,8 +138,7 @@ status = t.status; ## Notes -- The function accepts additional arguments to invoke the function with. These arguments are provided to the supplied function in the same order as provided to the `delay` function. -- In contrast to using `setTimeout`, which returns a timeout identifier that can be used to clear a pending invocation by calling `clearTimeout`, the `delay` function returns a `timeout` object with additional properties and methods. +- In contrast to using [`setTimeout`][mdn-settimeout], which returns a timeout identifier that can be used to clear a pending invocation by calling `clearTimeout`, the `delay` function returns a `timeout` object with additional properties and methods. @@ -168,7 +169,7 @@ var t1 = delay( beep, 3000 ); var t2 = delay( boop, 1000 ); var t3 = delay( baz, 4000 ); -t1.clear(); +t2.clear(); // Wait 3 seconds... // => beep From 9f2d294db2e80224a886ebcd2ffa2ad1d5369738 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 14 Oct 2022 18:21:11 -0700 Subject: [PATCH 07/24] Add empty line --- lib/node_modules/@stdlib/utils/delay/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 128c9f3d94db..c12250f003ff 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -128,6 +128,7 @@ A status may be one of the following values: - `0`: function invocation is pending. - `1`: function invocation is complete. - `2`: function invocation has been cleared. + From a1b2f5b022077b985046210e173b052195620004 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 14 Oct 2022 18:21:45 -0700 Subject: [PATCH 08/24] Fix missing line --- lib/node_modules/@stdlib/utils/delay/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index c12250f003ff..5ee8cf76bfe2 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -67,6 +67,7 @@ var t = delay( add, 3000, 2, 3 ); ``` The function returns a `timeout` object having properties and methods as documented below. + #### timeout.clear() Clears a pending invocation of a function. From 0dc9b83901438c6d034d1cc53941238040780e48 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 14 Oct 2022 18:28:51 -0700 Subject: [PATCH 09/24] Update copy --- lib/node_modules/@stdlib/utils/delay/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 5ee8cf76bfe2..ea57e6ace765 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -140,7 +140,7 @@ A status may be one of the following values: ## Notes -- In contrast to using [`setTimeout`][mdn-settimeout], which returns a timeout identifier that can be used to clear a pending invocation by calling `clearTimeout`, the `delay` function returns a `timeout` object with additional properties and methods. +- In contrast to [`setTimeout`][mdn-settimeout] which returns a timeout identifier and requires passing this identifier to `clearTimeout` in order to clear a pending invocation, the `delay` function returns a `timeout` object with additional properties and methods. From 717fa7be166c6e1dad539d391143194931c8c3ec Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 14 Oct 2022 18:29:25 -0700 Subject: [PATCH 10/24] Add link --- lib/node_modules/@stdlib/utils/delay/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index ea57e6ace765..ac50dd2bc2d5 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -140,7 +140,7 @@ A status may be one of the following values: ## Notes -- In contrast to [`setTimeout`][mdn-settimeout] which returns a timeout identifier and requires passing this identifier to `clearTimeout` in order to clear a pending invocation, the `delay` function returns a `timeout` object with additional properties and methods. +- In contrast to [`setTimeout`][mdn-settimeout] which returns a timeout identifier and requires passing this identifier to [`clearTimeout`][mdn-cleartimeout] in order to clear a pending invocation, the `delay` function returns a `timeout` object with additional properties and methods. From 4eda8e9681d5c86641ca13d60322ef920f34f0c8 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 1 Nov 2022 11:31:47 -0400 Subject: [PATCH 11/24] Add links and duration string notes --- .../@stdlib/utils/delay/README.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index ac50dd2bc2d5..49c2b4ace578 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -54,6 +54,18 @@ var t = delay( beep, 3000 ); // returns ``` +The `duration` parameter is specified in milliseconds or as a [duration string](#notes-duration-string) (e.g., `'5s'`, `'10m3s'`, `'2h'`, etc). + +```javascript +function beep() { + console.log( 'beep' ); +} + +// Invoke a function after 3 seconds: +var t = delay( beep, '3s' ); +// returns +``` + The function supports providing additional arguments to pass through to the delayed function upon invocation. The delayed function receives additional arguments in the same order in which they are provided to `delay`. ```javascript @@ -142,6 +154,20 @@ A status may be one of the following values: - In contrast to [`setTimeout`][mdn-settimeout] which returns a timeout identifier and requires passing this identifier to [`clearTimeout`][mdn-cleartimeout] in order to clear a pending invocation, the `delay` function returns a `timeout` object with additional properties and methods. + + +- A duration string is a string containing a sequence of time units. A time unit is a nonnegative integer followed by a unit identifier. The following unit identifiers are supported: + + - `d`: days + - `h`: hours + - `m`: minutes + - `s`: seconds + - `ms`: milliseconds + + For example, the string `1m3s10ms` is a duration string containing three time units: `1m` (1 minute), `3s` (3 seconds), and `10ms` (10 milliseconds). The string `60m` is a duration string containing a single time unit: `60m` (60 minutes). + +- Duration strings are case insensitive. For example, the string `1M3S10MS` is equivalent to `1m3s10ms`. + @@ -204,6 +230,10 @@ t2.clear(); From 700d40f52756210f8c4542ef4098a30b112915af Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 1 Nov 2022 11:49:26 -0400 Subject: [PATCH 12/24] Add note and CLI section --- .../@stdlib/utils/delay/README.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 49c2b4ace578..393a6940fb6b 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -154,6 +154,8 @@ A status may be one of the following values: - In contrast to [`setTimeout`][mdn-settimeout] which returns a timeout identifier and requires passing this identifier to [`clearTimeout`][mdn-cleartimeout] in order to clear a pending invocation, the `delay` function returns a `timeout` object with additional properties and methods. +- Browsers internally limit the maximum duration of a timeout to 32-bit signed integers (approximately 24.8 days). If a duration exceeds this limit, the function will invoke a function after the maximum duration. + - A duration string is a string containing a sequence of time units. A time unit is a nonnegative integer followed by a unit identifier. The following unit identifiers are supported: @@ -210,6 +212,56 @@ t2.clear(); +* * * + +
+ +## CLI + +
+ +### Usage + +```text +Usage: delay [options] + +Options: + + -h, --help Print this message. + -V, --version Print the package version. +``` + +
+ + + +
+ +### Notes + +- The CLI sleeps for a specified duration before exiting. +- The `duration` is specified in seconds or as a [duration string](#notes-duration-string) (e.g., `'5s'`, `'10m3s'`, `'2h'`, etc). + +
+ + + +
+ +### Examples + +```bash +$ delay 5 +``` + +
+ + + +
+ + +
From c10b642746a86d5933c1d398382ee56c04284471 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 2 Nov 2022 00:04:14 -0700 Subject: [PATCH 13/24] Update copy --- lib/node_modules/@stdlib/utils/delay/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 393a6940fb6b..0f1a0909811e 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -54,7 +54,7 @@ var t = delay( beep, 3000 ); // returns ``` -The `duration` parameter is specified in milliseconds or as a [duration string](#notes-duration-string) (e.g., `'5s'`, `'10m3s'`, `'2h'`, etc). +The `duration` parameter may be specified in milliseconds or as a [duration string](#notes-duration-string) (e.g., `'5s'`, `'10m3s'`, `'2h'`, etc). ```javascript function beep() { From 9d38f2bdcfb8fd90d72184958c1802840e5a7762 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 2 Nov 2022 00:05:57 -0700 Subject: [PATCH 14/24] Remove stray link --- lib/node_modules/@stdlib/utils/delay/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 0f1a0909811e..0d22f99dd9fd 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -156,8 +156,6 @@ A status may be one of the following values: - Browsers internally limit the maximum duration of a timeout to 32-bit signed integers (approximately 24.8 days). If a duration exceeds this limit, the function will invoke a function after the maximum duration. - - - A duration string is a string containing a sequence of time units. A time unit is a nonnegative integer followed by a unit identifier. The following unit identifiers are supported: - `d`: days From c39c6e6f477af20134f75f80f7fde31cf1b1cecf Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 2 Nov 2022 00:07:19 -0700 Subject: [PATCH 15/24] Update copy --- lib/node_modules/@stdlib/utils/delay/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 0d22f99dd9fd..1f41c0608efd 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -237,7 +237,7 @@ Options: ### Notes -- The CLI sleeps for a specified duration before exiting. +- The process sleeps for a specified duration before exiting. - The `duration` is specified in seconds or as a [duration string](#notes-duration-string) (e.g., `'5s'`, `'10m3s'`, `'2h'`, etc). From 41ff87fa9483b75eddaa3c21dd0c1978c2414c15 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 2 Nov 2022 00:08:15 -0700 Subject: [PATCH 16/24] Update copy --- lib/node_modules/@stdlib/utils/delay/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 1f41c0608efd..9867f3081ae1 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -154,7 +154,7 @@ A status may be one of the following values: - In contrast to [`setTimeout`][mdn-settimeout] which returns a timeout identifier and requires passing this identifier to [`clearTimeout`][mdn-cleartimeout] in order to clear a pending invocation, the `delay` function returns a `timeout` object with additional properties and methods. -- Browsers internally limit the maximum duration of a timeout to 32-bit signed integers (approximately 24.8 days). If a duration exceeds this limit, the function will invoke a function after the maximum duration. +- Browsers internally limit the maximum duration of a timeout to 32-bit signed integers (approximately 24.8 days). If a duration exceeds this limit, the function will invoke a provided function after the maximum duration. - A duration string is a string containing a sequence of time units. A time unit is a nonnegative integer followed by a unit identifier. The following unit identifiers are supported: From cada44d9e4973ab9111816d6d099260e23a670d7 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 20 Feb 2023 22:28:57 -0500 Subject: [PATCH 17/24] Update lib/node_modules/@stdlib/utils/delay/lib/main.js Co-authored-by: Athan --- lib/node_modules/@stdlib/utils/delay/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/delay/lib/main.js b/lib/node_modules/@stdlib/utils/delay/lib/main.js index 32de4b832f95..2b117fcbfccf 100644 --- a/lib/node_modules/@stdlib/utils/delay/lib/main.js +++ b/lib/node_modules/@stdlib/utils/delay/lib/main.js @@ -31,7 +31,7 @@ * @private * @param {Function} fcn - function to invoke * @param {NonNegativeInteger} wait - wait duration (in milliseconds) -* @param {...*} [args] - arguments to invoke `fcn` with +* @param {...*} [args] - arguments with which to invoke `fcn` * @returns {TimeoutObject} timeout object * * @example From e789233014c975a8937156d7a166ee6920bc0e92 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 29 May 2023 10:58:22 -0400 Subject: [PATCH 18/24] Update lib/node_modules/@stdlib/utils/delay/test/test.js Co-authored-by: Athan --- lib/node_modules/@stdlib/utils/delay/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/delay/test/test.js b/lib/node_modules/@stdlib/utils/delay/test/test.js index 7f4787209235..81976d122f1b 100644 --- a/lib/node_modules/@stdlib/utils/delay/test/test.js +++ b/lib/node_modules/@stdlib/utils/delay/test/test.js @@ -47,7 +47,7 @@ tape( 'the function delays execution by a specified number of milliseconds', fun } }); -tape( 'if the function is called with additional arguments, the function is invoked with those arguments', function test( t ) { +tape( 'if the function is called with additional arguments, the provided function is invoked with those arguments', function test( t ) { var out; var i = setTimeout( onTimeout, 1000 ); From 6d4061981d6bc64d410cddb36c3fcebd247bb213 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 29 May 2023 10:58:59 -0400 Subject: [PATCH 19/24] Update lib/node_modules/@stdlib/utils/delay/docs/repl.txt Co-authored-by: Athan --- lib/node_modules/@stdlib/utils/delay/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/delay/docs/repl.txt b/lib/node_modules/@stdlib/utils/delay/docs/repl.txt index 49f65b228025..310b9a559ffa 100644 --- a/lib/node_modules/@stdlib/utils/delay/docs/repl.txt +++ b/lib/node_modules/@stdlib/utils/delay/docs/repl.txt @@ -11,7 +11,7 @@ Milliseconds to wait before invoking a function. args: ...any - Additional arguments to invoke the function with. + Additional arguments with which to invoke the function. Returns ------- From 041fea8bc2f1a7223ae2470b0a3ad798daf93668 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 29 May 2023 10:59:19 -0400 Subject: [PATCH 20/24] Update lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts Co-authored-by: Athan --- lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts index c8922d410c7f..c45cac910ae1 100644 --- a/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts @@ -24,7 +24,7 @@ * @private * @param fcn - function to invoke * @param wait - wait duration (in milliseconds) -* @param args - arguments to invoke `fcn` with +* @param args - arguments with which to invoke `fcn` * @returns timeout object * * @example From 3ec6a90c6ede265779c90074c7f74c358ac5db50 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 10 Dec 2023 16:03:53 -0500 Subject: [PATCH 21/24] fix: address feedback from code review --- .../utils/delay/benchmark/benchmark.js | 12 +++++------- .../@stdlib/utils/delay/lib/index.js | 1 - .../@stdlib/utils/delay/test/test.js | 19 ------------------- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js index c52536fcf313..bc4c4f7b22ac 100644 --- a/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js @@ -29,17 +29,12 @@ var delay = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var fn; var t; var i; - fn = function beep() { - console.log( 'beep' ); - }; - b.tic(); for ( i = 0; i < b.iterations; i++ ) { - t = delay( fn, 1000 ); + t = delay( beep, 1000 ); if ( typeof t.status !== 'number' ) { b.fail( 'should return a timeout object' ); } @@ -50,5 +45,8 @@ bench( pkg, function benchmark( b ) { } b.pass( 'benchmark finished' ); b.end(); -}); + function beep() { + console.log( 'beep' ); + } +}); diff --git a/lib/node_modules/@stdlib/utils/delay/lib/index.js b/lib/node_modules/@stdlib/utils/delay/lib/index.js index 6788fe2ec0b5..9365c7e3e589 100644 --- a/lib/node_modules/@stdlib/utils/delay/lib/index.js +++ b/lib/node_modules/@stdlib/utils/delay/lib/index.js @@ -18,7 +18,6 @@ 'use strict'; - /** * Invoke a function after a specified number of milliseconds. * diff --git a/lib/node_modules/@stdlib/utils/delay/test/test.js b/lib/node_modules/@stdlib/utils/delay/test/test.js index 81976d122f1b..a784c48b65ec 100644 --- a/lib/node_modules/@stdlib/utils/delay/test/test.js +++ b/lib/node_modules/@stdlib/utils/delay/test/test.js @@ -135,22 +135,3 @@ tape( 'the returned timeout object exposes a property for getting the timeout st t.end(); } }); - -tape( 'the returned timeout object exposes a property for getting the timeout status', function test( t ) { - var out; - var i = setTimeout( onTimeout, 1000 ); - - function onTimeout() { - out = true; - clearTimeout( i ); - t.ok( false, 'should not be invoked' ); - t.end(); - } - - i.clear(); - if ( out ) { - t.ok( false, 'should not be invoked' ); - t.end(); - } else { - t.equal( i.status, 2, 'returns status' ); - t.end(); From a70cb9369ac22cf21feb745127826109c3af9424 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 10 Dec 2023 16:23:16 -0500 Subject: [PATCH 22/24] test: comment out tests for now --- lib/node_modules/@stdlib/utils/delay/test/test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/utils/delay/test/test.js b/lib/node_modules/@stdlib/utils/delay/test/test.js index a784c48b65ec..c7e9d5febd04 100644 --- a/lib/node_modules/@stdlib/utils/delay/test/test.js +++ b/lib/node_modules/@stdlib/utils/delay/test/test.js @@ -32,6 +32,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +/* tape( 'the function delays execution by a specified number of milliseconds', function test( t ) { var out = false; var i = setTimeout( onTimeout, 1000 ); @@ -135,3 +136,4 @@ tape( 'the returned timeout object exposes a property for getting the timeout st t.end(); } }); +*/ From 44fafb53106fc6acb2fd2e38f9481d5df79f3cc8 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sat, 24 Feb 2024 21:30:19 +0000 Subject: [PATCH 23/24] chore: update copyright years --- lib/node_modules/@stdlib/utils/delay/README.md | 2 +- lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js | 2 +- lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/utils/delay/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/utils/delay/examples/index.js | 2 +- lib/node_modules/@stdlib/utils/delay/lib/index.js | 2 +- lib/node_modules/@stdlib/utils/delay/lib/main.js | 2 +- lib/node_modules/@stdlib/utils/delay/test/test.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/delay/README.md b/lib/node_modules/@stdlib/utils/delay/README.md index 9867f3081ae1..a599584f3cc2 100644 --- a/lib/node_modules/@stdlib/utils/delay/README.md +++ b/lib/node_modules/@stdlib/utils/delay/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2022 The Stdlib Authors. +Copyright (c) 2024 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js index bc4c4f7b22ac..7fdbd2d7d453 100644 --- a/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/utils/delay/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts index c45cac910ae1..0786bffc714e 100644 --- a/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/delay/docs/types/index.d.ts @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/utils/delay/docs/types/test.ts b/lib/node_modules/@stdlib/utils/delay/docs/types/test.ts index eea1f6b9b179..69c5ac2fb2ba 100644 --- a/lib/node_modules/@stdlib/utils/delay/docs/types/test.ts +++ b/lib/node_modules/@stdlib/utils/delay/docs/types/test.ts @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/utils/delay/examples/index.js b/lib/node_modules/@stdlib/utils/delay/examples/index.js index dfa820d761f8..a76982276e61 100644 --- a/lib/node_modules/@stdlib/utils/delay/examples/index.js +++ b/lib/node_modules/@stdlib/utils/delay/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/utils/delay/lib/index.js b/lib/node_modules/@stdlib/utils/delay/lib/index.js index 9365c7e3e589..3be9558ce4f3 100644 --- a/lib/node_modules/@stdlib/utils/delay/lib/index.js +++ b/lib/node_modules/@stdlib/utils/delay/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/utils/delay/lib/main.js b/lib/node_modules/@stdlib/utils/delay/lib/main.js index 2b117fcbfccf..43ab1a95bed4 100644 --- a/lib/node_modules/@stdlib/utils/delay/lib/main.js +++ b/lib/node_modules/@stdlib/utils/delay/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/utils/delay/test/test.js b/lib/node_modules/@stdlib/utils/delay/test/test.js index c7e9d5febd04..958097efddd4 100644 --- a/lib/node_modules/@stdlib/utils/delay/test/test.js +++ b/lib/node_modules/@stdlib/utils/delay/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 8faa10d7d01e344a7af4d4ec735c8ad7734b9b3b Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 15 Jan 2025 09:07:34 -0500 Subject: [PATCH 24/24] chore: format code in delay examples --- lib/node_modules/@stdlib/utils/delay/examples/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/delay/examples/index.js b/lib/node_modules/@stdlib/utils/delay/examples/index.js index a76982276e61..53e3dfc8a65c 100644 --- a/lib/node_modules/@stdlib/utils/delay/examples/index.js +++ b/lib/node_modules/@stdlib/utils/delay/examples/index.js @@ -21,16 +21,16 @@ var delay = require( './../lib' ); function beep() { - console.log( 'beep' ); + console.log( 'beep' ); } function boop() { - console.log( 'boop' ); + console.log( 'boop' ); } function baz() { - console.log( 'baz' ); + console.log( 'baz' ); } -var t1 = delay( beep, 3000 ); +var t1 = delay( beep, 3000 ); var t2 = delay( boop, 1000 ); var t3 = delay( baz, 4000 );