diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/README__md.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/README__md.txt index f9072c57a0ff..f2973c04fd55 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/README__md.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/README__md.txt @@ -18,6 +18,8 @@ limitations under the License. --> + + # {{ALIAS}} > {{PKG_DESC}} @@ -90,11 +92,11 @@ The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the ```javascript -var uniform = require( '@stdlib/random/iter/uniform' ); +var random = require( '@stdlib/random/iter/{{BASE_PRNG}}' ); var {{ALIAS}} = require( '@{{PKG}}' ); // Create a seeded iterator for generating pseudorandom numbers: -var rand = uniform( {{RAND_MIN}}, {{RAND_MAX}}, { +var rand = random( {{RAND_MIN}}, {{RAND_MAX}}, { 'seed': 1234, 'iter': 10 }); @@ -139,7 +141,7 @@ while ( true ) { [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol -[@{{UNARY_PKG}}]: https://github.com/stdlib-js/stdlib +[@{{UNARY_PKG}}]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40{{UNARY_PKG}} diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/benchmark/benchmark__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/benchmark/benchmark__js.txt index 89b004489745..78848d579d2a 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/benchmark/benchmark__js.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/benchmark/benchmark__js.txt @@ -16,12 +16,14 @@ * limitations under the License. */ +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + 'use strict'; // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/iter/uniform' ); +var random = require( '@stdlib/random/iter/{{BASE_PRNG}}' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); var pkg = require( './../package.json' ).name; @@ -35,7 +37,7 @@ bench( pkg, function benchmark( b ) { var iter; var i; - rand = uniform( {{RAND_MIN}}, {{RAND_MAX}} ); + rand = random( {{RAND_MIN}}, {{RAND_MAX}} ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -58,7 +60,7 @@ bench( pkg+'::iteration', function benchmark( b ) { var z; var i; - rand = uniform( {{RAND_MIN}}, {{RAND_MAX}} ); + rand = random( {{RAND_MIN}}, {{RAND_MAX}} ); iter = {{ALIAS}}( rand ); b.tic(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/repl__txt.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/repl__txt.txt index 51dd8f371ae7..c0458783769b 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/repl__txt.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/repl__txt.txt @@ -25,12 +25,12 @@ Examples -------- - > var r = {{alias:@stdlib/random/iter/uniform}}( {{RAND_MIN}}, {{RAND_MAX}} ); + > var r = {{alias:@stdlib/random/iter/{{BASE_PRNG}}}}( {{RAND_MIN}}, {{RAND_MAX}} ); > var it = {{alias}}( r ); > var v = it.next().value - + <{{JAVASCRIPT_RETURN_TYPE}}> > v = it.next().value - + <{{JAVASCRIPT_RETURN_TYPE}}> See Also -------- diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/types/index__d__ts.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/types/index__d__ts.txt index faed663d7c49..c7f9778699d2 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/types/index__d__ts.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/types/index__d__ts.txt @@ -16,11 +16,13 @@ * limitations under the License. */ +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + // TypeScript Version: 4.1 /// -import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; +import { TypedIterator as Iter, TypedIterableIterator as IterableIterator } from '@stdlib/types/iter'; // Define a union type representing both iterable and non-iterable iterators: type Iterator = Iter | IterableIterator; @@ -36,22 +38,22 @@ type Iterator = Iter | IterableIterator; * @returns iterator * * @example -* var uniform = require( `@stdlib/random/iter/uniform` ); +* var random = require( '@stdlib/random/iter/{{BASE_PRNG}}' ); * -* var iter = {{ALIAS}}( uniform( {{RAND_MIN}}, {{RAND_MAX}} ) ); +* var iter = {{ALIAS}}( random( {{RAND_MIN}}, {{RAND_MAX}} ) ); * * var v = iter.next().value; -* // returns +* // returns <{{JAVASCRIPT_RETURN_TYPE}}> * * v = iter.next().value; -* // returns +* // returns <{{JAVASCRIPT_RETURN_TYPE}}> * * v = iter.next().value; -* // returns +* // returns <{{JAVASCRIPT_RETURN_TYPE}}> * * // ... */ -declare function {{ALIAS}}( iterator: Iterator ): Iterator; +declare function {{ALIAS}}( iterator: Iterator<{{JAVASCRIPT_RETURN_TYPE}}> ): Iterator<{{JAVASCRIPT_RETURN_TYPE}}>; // EXPORTS // diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/types/test__ts.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/types/test__ts.txt index f3d461a94ae3..3dcc7000ec70 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/types/test__ts.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/docs/types/test__ts.txt @@ -16,6 +16,8 @@ * limitations under the License. */ +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + import {{ALIAS}} = require( './index' ); /** @@ -36,7 +38,7 @@ function iterator() { */ function next() { return { - 'value': true, + 'value': 1.0, 'done': false }; } @@ -46,7 +48,7 @@ function next() { // The function returns an iterator... { - {{ALIAS}}( iterator() ); // $ExpectType TypedIterator + {{ALIAS}}( iterator() ); // $ExpectType TypedIterator<{{JAVASCRIPT_RETURN_TYPE}}> } // The compiler throws an error if the function is provided a first argument which is not an iterator protocol-compliant object... diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/examples/index__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/examples/index__js.txt index 694e1c55d369..1dd2292efa33 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/examples/index__js.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/examples/index__js.txt @@ -16,13 +16,15 @@ * limitations under the License. */ +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + 'use strict'; -var uniform = require( '@stdlib/random/iter/uniform' ); +var random = require( '@stdlib/random/iter/{{BASE_PRNG}}' ); var {{ALIAS}} = require( './../lib' ); // Create a seeded iterator for generating pseudorandom numbers: -var rand = uniform( {{RAND_MIN}}, {{RAND_MAX}}, { +var rand = random( {{RAND_MIN}}, {{RAND_MAX}}, { 'seed': 1234, 'iter': 10 }); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/lib/index__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/lib/index__js.txt index 9a2d41e328f1..af4a3b529d1d 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/lib/index__js.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/lib/index__js.txt @@ -16,6 +16,8 @@ * limitations under the License. */ +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + 'use strict'; /** @@ -24,28 +26,28 @@ * @module @{{PKG}} * * @example -* var uniform = require( '@stdlib/random/iter/uniform' ); +* var random = require( '@stdlib/random/iter/{{BASE_PRNG}}' ); * var {{ALIAS}} = require( '@{{PKG}}' ); * -* var iter = {{ALIAS}}( uniform( {{RAND_MIN}}, {{RAND_MAX}} ) ); +* var iter = {{ALIAS}}( random( {{RAND_MIN}}, {{RAND_MAX}} ) ); * * var v = iter.next().value; -* // returns +* // returns <{{JAVASCRIPT_RETURN_TYPE}}> * * v = iter.next().value; -* // returns +* // returns <{{JAVASCRIPT_RETURN_TYPE}}> * * v = iter.next().value; -* // returns +* // returns <{{JAVASCRIPT_RETURN_TYPE}}> * * // ... */ // MODULES // -var iterator = require( './main.js' ); +var main = require( './main.js' ); // EXPORTS // -module.exports = iterator; +module.exports = main; diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/lib/main__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/lib/main__js.txt index e6a8a3323d6a..23cfb8e1a8ae 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/lib/main__js.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/lib/main__js.txt @@ -16,6 +16,8 @@ * limitations under the License. */ +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + 'use strict'; // MODULES // @@ -38,18 +40,18 @@ var {{UNARY_ALIAS}} = require( '@{{UNARY_PKG}}' ); * @returns {Iterator} iterator * * @example -* var uniform = require( '@stdlib/random/iter/uniform' ); +* var random = require( '@stdlib/random/iter/{{BASE_PRNG}}' ); * -* var iter = {{ALIAS}}( uniform( {{RAND_MIN}}, {{RAND_MAX}} ) ); +* var iter = {{ALIAS}}( random( {{RAND_MIN}}, {{RAND_MAX}} ) ); * * var v = iter.next().value; -* // returns +* // returns <{{JAVASCRIPT_RETURN_TYPE}}> * * v = iter.next().value; -* // returns +* // returns <{{JAVASCRIPT_RETURN_TYPE}}> * * v = iter.next().value; -* // returns +* // returns <{{JAVASCRIPT_RETURN_TYPE}}> * * // ... */ diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/package__json.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/package__json.txt index f6262591b56e..d4a2d40567d2 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/package__json.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/package__json.txt @@ -49,7 +49,10 @@ "windows" ], "keywords": [ - "stdlib",{{KEYWORDS}} + "stdlib", + "stdmath", + "math", + "mathematics",{{KEYWORDS}} "iterator", "iterable", "iterate" diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/test/test__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/test/test__js.txt index be0767e14f53..d762da70e64d 100644 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/test/test__js.txt +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/data/test/test__js.txt @@ -16,13 +16,14 @@ * limitations under the License. */ +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + 'use strict'; // MODULES // var tape = require( 'tape' ); -var uniform = require( '@stdlib/random/iter/uniform' ); -var linspace = require( '@stdlib/iter/linspace' ); +var random = require( '@stdlib/random/iter/{{BASE_PRNG}}' ); var array2iterator = require( '@stdlib/array/to-iterator' ); var {{UNARY_ALIAS}} = require( '@{{UNARY_PKG}}' ); var {{ALIAS}} = require( './../lib' ); @@ -32,7 +33,7 @@ var {{ALIAS}} = require( './../lib' ); tape( 'main export is a function', function test( t ) { t.ok( true, __filename ); - t.equal( typeof {{ALIAS}}, 'function', 'main export is a function' ); + t.strictEqual( typeof {{ALIAS}}, 'function', 'main export is a function' ); t.end(); }); @@ -66,23 +67,28 @@ tape( 'the function throws an error if provided an iterator argument which is no }); tape( 'the function returns an iterator protocol-compliant object', function test( t ) { + var rand; var it; var r; var i; - it = {{ALIAS}}( uniform( {{RAND_MIN}}, {{RAND_MAX}} ) ); - t.equal( it.next.length, 0, 'has zero arity' ); + rand = random( {{RAND_MIN}}, {{RAND_MAX}}, { + 'seed': 1234 + }); + it = {{ALIAS}}( rand ); + t.strictEqual( it.next.length, 0, 'has zero arity' ); for ( i = 0; i < 100; i++ ) { r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); + t.strictEqual( typeof r.value, '{{JAVASCRIPT_RETURN_TYPE}}', 'returns expected value' ); + t.strictEqual( typeof r.done, 'boolean', 'returns expected value' ); } t.end(); }); tape( 'the function returns an iterator protocol-compliant object which {{TEST_DESC}}', function test( t ) { var expected; + var rand; var it; var N; var x; @@ -90,19 +96,27 @@ tape( 'the function returns an iterator protocol-compliant object which {{TEST_D var i; N = 100; - it = {{ALIAS}}( linspace( {{RAND_MIN}}, {{RAND_MAX}}, N ) ); - t.equal( it.next.length, 0, 'has zero arity' ); - x = linspace( {{RAND_MIN}}, {{RAND_MAX}}, N ); + rand = random( {{RAND_MIN}}, {{RAND_MAX}}, { + 'seed': 1234, + 'iter': N + }); + it = {{ALIAS}}( rand ); + t.strictEqual( it.next.length, 0, 'has zero arity' ); + + x = random( {{RAND_MIN}}, {{RAND_MAX}}, { + 'seed': 1234, + 'iter': N + }); for ( i = 0; i < N; i++ ) { r = it.next(); expected = {{UNARY_ALIAS}}( x.next().value ); - t.equal( r.value, expected, 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); + t.strictEqual( r.value, expected, 'returns expected value' ); + t.strictEqual( typeof r.done, 'boolean', 'returns expected value' ); } r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); + t.strictEqual( r.value, void 0, 'returns expected value' ); + t.strictEqual( r.done, true, 'returns expected value' ); t.end(); }); @@ -147,17 +161,17 @@ tape( 'the function returns an iterator protocol-compliant object which returns ]; it = {{ALIAS}}( array2iterator( values ) ); - t.equal( it.next.length, 0, 'has zero arity' ); + t.strictEqual( it.next.length, 0, 'has zero arity' ); for ( i = 0; i < expected.length; i++ ) { actual = it.next(); r = expected[ i ].value; if ( r === r ) { - t.equal( actual.value, r, 'returns expected value' ); + t.strictEqual( actual.value, r, 'returns expected value' ); } else { t.notEqual( actual.value, actual.value, 'returns expected value' ); } - t.equal( actual.done, expected[ i ].done, 'returns expected value' ); + t.strictEqual( actual.done, expected[ i ].done, 'returns expected value' ); } t.end(); }); @@ -166,23 +180,23 @@ tape( 'the returned iterator has a `return` method for closing an iterator (no a var it; var r; - it = {{ALIAS}}( uniform( {{RAND_MIN}}, {{RAND_MAX}} ) ); + it = {{ALIAS}}( random( {{RAND_MIN}}, {{RAND_MAX}} ) ); r = it.next(); - t.equal( typeof r.value, 'number', 'returns expected value' ); - t.equal( r.done, false, 'returns expected value' ); + t.strictEqual( typeof r.value, '{{JAVASCRIPT_RETURN_TYPE}}', 'returns expected value' ); + t.strictEqual( r.done, false, 'returns expected value' ); r = it.next(); - t.equal( typeof r.value, 'number', 'returns expected value' ); - t.equal( r.done, false, 'returns expected value' ); + t.strictEqual( typeof r.value, '{{JAVASCRIPT_RETURN_TYPE}}', 'returns expected value' ); + t.strictEqual( r.done, false, 'returns expected value' ); r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); + t.strictEqual( r.value, void 0, 'returns expected value' ); + t.strictEqual( r.done, true, 'returns expected value' ); r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); + t.strictEqual( r.value, void 0, 'returns expected value' ); + t.strictEqual( r.done, true, 'returns expected value' ); t.end(); }); @@ -191,23 +205,23 @@ tape( 'the returned iterator has a `return` method for closing an iterator (argu var it; var r; - it = {{ALIAS}}( uniform( {{RAND_MIN}}, {{RAND_MAX}} ) ); + it = {{ALIAS}}( random( {{RAND_MIN}}, {{RAND_MAX}} ) ); r = it.next(); - t.equal( typeof r.value, 'number', 'returns expected value' ); - t.equal( r.done, false, 'returns expected value' ); + t.strictEqual( typeof r.value, '{{JAVASCRIPT_RETURN_TYPE}}', 'returns expected value' ); + t.strictEqual( r.done, false, 'returns expected value' ); r = it.next(); - t.equal( typeof r.value, 'number', 'returns expected value' ); - t.equal( r.done, false, 'returns expected value' ); + t.strictEqual( typeof r.value, '{{JAVASCRIPT_RETURN_TYPE}}', 'returns expected value' ); + t.strictEqual( r.done, false, 'returns expected value' ); r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); + t.strictEqual( r.value, 'finished', 'returns expected value' ); + t.strictEqual( r.done, true, 'returns expected value' ); r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); + t.strictEqual( r.value, void 0, 'returns expected value' ); + t.strictEqual( r.done, true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/scripts/runner.js b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/scripts/runner.js new file mode 100644 index 000000000000..a76eeb5d1e77 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/scripts/runner.js @@ -0,0 +1,279 @@ +#!/usr/bin/env node + +/** +* @license Apache-2.0 +* +* 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. +* 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 resolve = require( 'path' ).resolve; +var shell = require( 'child_process' ).execSync; // eslint-disable-line node/no-sync +var existsSync = require( '@stdlib/fs/exists' ).sync; +var objectKeys = require( '@stdlib/utils/keys' ); +var rootDir = require( '@stdlib/_tools/utils/root-dir' ); +var log = require( '@stdlib/console/log' ); +var capitalize = require( '@stdlib/string/capitalize' ); +var isInteger = require( '@stdlib/math/base/assert/is-integer' ); +var isRealFloatingDataType = require( '@stdlib/array/base/assert/is-real-floating-point-data-type' ); +var DATA = require( './data.json' ); + + +// VARIABLES // + +var CREATE_ONLY = 1; +var SCAFFOLD_SCRIPT = resolve( __dirname, 'scaffold.sh' ); +var ROOT_DIR = resolve( rootDir(), 'lib', 'node_modules' ); + + +// FUNCTIONS // + +/** +* Returns an `ALIAS` environment variable string. +* +* @private +* @param {string} alias - package alias +* @returns {string} environment variable string +* +* @example +* var s = aliasEnvVar( 'abs' ); +* // returns 'ALIAS=iterAbs' +* +* @example +* var s = aliasEnvVar( 'absf' ); +* // returns 'ALIAS=iterAbsf' +*/ +function aliasEnvVar( alias ) { + return 'ALIAS=iter' + capitalize( alias ); +} + +/** +* Returns a `DESC` environment variable string. +* +* @private +* @param {string} desc - default description +* @returns {string} environment variable string +* +* @example +* var s = descEnvVar( 'computes the cube root' ); +* // returns 'DESC=\'computes the cube root\'' +*/ +function descEnvVar( desc ) { + return 'DESC=\'' + desc + '\''; +} + +/** +* Returns a `DESC_LINK_TEXT` environment variable string. +* +* @private +* @param {string} desc - short description +* @returns {string} environment variable string +* +* @example +* var s = linkTextEnvVar( 'cube root' ); +* // returns 'DESC_LINK_TEXT=\'cube root\'' +* +* @example +* var s = linkTextEnvVar( '' ); +* // returns '' +*/ +function linkTextEnvVar( desc ) { + if ( desc === '' ) { + return ''; + } + return 'DESC_LINK_TEXT=\'' + desc + '\''; +} + +/** +* Returns a `KEYWORDS` environment variable string. +* +* @private +* @param {StringArray} keywords - list of keywords +* @returns {string} environment variable string +* +* @example +* var keywords = [ 'math', 'special' ]; +* +* var s = keywordsEnvVar( keywords ); +* // returns 'KEYWORDS=\'math,special\'' +*/ +function keywordsEnvVar( keywords ) { + return 'KEYWORDS=\'' + keywords.join( ',' ) + '\''; +} + +/** +* Returns a `VALUES_LEN_2` environment variable string. +* +* @private +* @param {NumberArray} values - example values +* @param {string} dtype - values data type +* @returns {string} environment variable string +* +* @example +* var values = [ 1, 2, 3, 4 ]; +* +* var s = valuesEnvVar( values, 'int32' ); +* // returns 'VALUES_LEN_2=\'1,2\'' +*/ +function valuesEnvVar( values, dtype ) { + var vals; + var v; + var i; + + if ( isRealFloatingDataType( dtype ) ) { + vals = []; + for ( i = 0; i < 2; i++ ) { + v = values[ i ]; + vals.push( v.toString() ); + if ( isInteger( v ) ) { + vals[ i ] += '.0'; + } + } + } else { + vals = values.slice( 0, 2 ); + } + return 'VALUES_LEN_2=\'' + vals.join( ',' ) + '\''; +} + +/** +* Returns a string containing environment variable for generating pseudorandom numbers. +* +* @private +* @param {Object} obj - configuration object +* @returns {string} environment variable string +* +* @example +* var o = { +* 'prng': 'random/base/uniform', +* 'parameters': [ -10, 10 ] +* }; +* +* var s = prngEnvVars( o ); +* // returns 'BASE_PRNG=\'uniform\',RAND_MIN=-10,RAND_MAX=10' +*/ +function prngEnvVars( obj ) { + var base; + var min; + var max; + var p; + + p = obj.prng.split( '/' ); + base = p[ p.length-1 ]; + min = obj.parameters[ 0 ]; + max = obj.parameters[ 1 ]; + if ( base === 'uniform' ) { + if ( isInteger( min ) ) { + min = min.toString() + '.0'; + } + if ( isInteger( max ) ) { + max = max.toString() + '.0'; + } + } else { + min = min.toString(); + max = max.toString(); + } + return [ + 'BASE_PRNG=\'' + base + '\'', + 'RAND_MIN=' + min, + 'RAND_MAX=' + max + ].join( ' ' ); +} + +/** +* Returns a `JAVASCRIPT_RETURN_TYPE` environment variable string. +* +* @private +* @param {string} dt - return type +* @returns {string} environment variable string +* +* @example +* var s = returnTypeEnvVar( 'number' ); +* // returns 'JAVASCRIPT_RETURN_TYPE=\'number\'' +*/ +function returnTypeEnvVar( dt ) { + return 'JAVASCRIPT_RETURN_TYPE=\'' + dt + '\''; +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var keys; + var envs; + var cmd; + var p; + var k; + var v; + var o; + var i; + var j; + + for ( i = 0; i < DATA.length; i++ ) { + o = DATA[ i ]; + p = resolve( ROOT_DIR, '@stdlib/math/iter/special', o.alias, 'package.json' ); + if ( existsSync( p ) ) { + if ( CREATE_ONLY ) { + log( 'Package already exists. Skipping @%s...', 'stdlib/math/iter/special/' + o.alias ); + continue; + } + log( 'Updating package: @%s...', 'stdlib/math/iter/special/' + o.alias ); + } else { + log( 'Creating package: @%s...', 'stdlib/math/iter/special/' + o.alias ); + } + keys = objectKeys( o ); + envs = []; + for ( j = 0; j < keys.length; j++ ) { + k = keys[ j ]; + v = o[ k ]; + if ( k === 'alias' ) { + envs.push( aliasEnvVar( v ) ); + continue; + } + if ( k === 'desc' ) { + envs.push( descEnvVar( v ) ); + continue; + } + if ( k === 'short_desc' ) { + envs.push( linkTextEnvVar( v ) ); + continue; + } + if ( k === 'keywords' ) { + envs.push( keywordsEnvVar( v ) ); + continue; + } + if ( k === 'parameters' ) { + envs.push( valuesEnvVar( v[ 0 ].example_values, v[ 0 ].type.dtype ) ); // eslint-disable-line max-len + envs.push( prngEnvVars( v[ 0 ].rand ) ); + continue; + } + if ( k === 'returns' ) { + envs.push( returnTypeEnvVar( v.type.javascript ) ); + continue; + } + } + cmd = envs.join( ' ' ) + ' . ' + SCAFFOLD_SCRIPT; + shell( cmd ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/scripts/scaffold.sh b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/scripts/scaffold.sh index 7d5eda80bbaa..2c4effa1966c 100755 --- a/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/scripts/scaffold.sh +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/scripts/scaffold.sh @@ -22,38 +22,41 @@ # # Environment Variables: # -# ALIAS Main export alias. -# PKG_DESC Package description. -# MODULE_DESC Module description. -# MAIN_DESC Main export description. -# TEST_DESC Test description. -# DESC_LINK_TEXT README link text. -# KEYWORDS List of keywords. -# RAND_MIN Minimum value for generated values. -# RAND_MAX Maximum value for generated values. -# VALUES_LEN_2 List of input values. +# ALIAS Main export alias. +# DESC Default description. +# PKG_DESC Package description. +# MODULE_DESC Module description. +# MAIN_DESC Main export description. +# TEST_DESC Test description. +# DESC_LINK_TEXT README link text. +# KEYWORDS List of keywords. +# BASE_PRNG Base name of the package for generating pseudorandom numbers. +# RAND_MIN Minimum value for generated values. +# RAND_MAX Maximum value for generated values. +# VALUES_LEN_2 List of input values. +# JAVASCRIPT_RETURN_TYPE JavaScript return value data type. # ## USER-DEFINED VARIABLES ## # Define the main export alias: -alias=${ALIAS:-'iterTest'} +alias=${ALIAS:-'iterTODO'} # Define the package description: # shellcheck disable=SC2016 -pkg_desc=${PKG_DESC:-'Create an iterator which computes `gamma(x+1) - 1` for each iterated value.'} +pkg_desc=${PKG_DESC:-"Create an iterator which iteratively ${DESC:-'TODO'}."} # Define the module description: # shellcheck disable=SC2016 -module_desc=${MODULE_DESC:-'Create an iterator which iteratively computes `gamma(x+1) - 1`.'} +module_desc=${MODULE_DESC:-"Create an iterator which iteratively ${DESC:-'TODO'}."} # Define main export description: # shellcheck disable=SC2016 -main_desc=${MAIN_DESC:-'Returns an iterator which iteratively computes `gamma(x+1) - 1` without cancellation errors for small `x`.'} +main_desc=${MAIN_DESC:-"Returns an iterator which iteratively ${DESC:-'TODO'}."} # Define the test description: # shellcheck disable=SC2016 -test_desc=${TEST_DESC:-'computes `gamma(x+1) - 1` for each iterated value'} +test_desc=${TEST_DESC:-"${DESC:-'TODO'} for each iterated value"} # Define description text (found in the README) which should be a link to the unary package (NOTE: to not include a link, set to an empty string): desc_link_text=${DESC_LINK_TEXT:-''} @@ -62,32 +65,30 @@ desc_link_text=${DESC_LINK_TEXT:-''} if [[ -z "${KEYWORDS:-}" ]]; then keywords=( "stdmath" - "mathematics" - "math" - "special function" - "special" - "function" - "gamma" - "gammap1m1" - "gamma1pm1" - "factorial" - "number" + "mathematics" + "math" ) else IFS=','; read -ra keywords <<< "${KEYWORDS}"; IFS=' '; fi +# Define the JavaScript return data type: +javascript_return_type=${JAVASCRIPT_RETURN_TYPE:-'number'} + +# Define a pseudorandom number generator for generating random values: +base_prng=${BASE_PRNG:-'uniform'} + # Define the minimum value of generated values when benchmarking and testing the implementation: -rand_min=${RAND_MIN:-'-5.0'} +rand_min=${RAND_MIN:-'-10.0'} # Define the maximum value of generated values when benchmarking and testing the implementation: -rand_max=${RAND_MAX:-'5.0'} +rand_max=${RAND_MAX:-'10.0'} # Define a list of input values: if [[ -z "${VALUES_LEN_2:-}" ]]; then values_len_2=( - '0.2' - '-8.5' + '1.0' + '2.0' ) else IFS=','; read -ra values_len_2 <<< "${VALUES_LEN_2}"; IFS=' '; @@ -147,7 +148,7 @@ unary_pkg_path="stdlib/math/base/special" unary_pkg="${unary_pkg_path}/${unary_pkg_alias}" # Define the REPL text main export description (note: 4 space indent and wrap at 80 characters): -repl_text_main_desc=$(echo -n "${main_desc}" | "${wrap}") +repl_text_main_desc=$(printf "%s" "${main_desc}" | "${wrap}") repl_text_main_desc="${repl_text_main_desc/ /}" # Define the copyright year: @@ -190,11 +191,13 @@ files=( ) # Create the destination directories... +# shellcheck disable=SC2048 for dir in ${dirs[*]}; do mkdir -p "${dest_dir}/${dir}" done # Copy the scaffold files to the destination directory... +# shellcheck disable=SC2048 for file in ${files[*]}; do cp "${this_dir}/data/${file//\./__}.txt" "${dest_dir}/${file}" done @@ -274,12 +277,18 @@ find_and_replace "${regex}" regex="s/\\{\\{UNARY_ALIAS\\}\\}/${unary_alias}/g;" find_and_replace "${regex}" +regex="s/\\{\\{BASE_PRNG\\}\\}/${base_prng}/g;" +find_and_replace "${regex}" + regex="s/\\{\\{RAND_MIN\\}\\}/${rand_min}/g;" find_and_replace "${regex}" regex="s/\\{\\{RAND_MAX\\}\\}/${rand_max}/g;" find_and_replace "${regex}" +regex="s/\\{\\{JAVASCRIPT_RETURN_TYPE\\}\\}/${javascript_return_type}/g;" +find_and_replace "${regex}" + keywords_sep='",\n "' if [ "${#keywords[*]}" -eq 0 ]; then words=''