diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/README.md b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/README.md new file mode 100644 index 000000000000..6f407dc14727 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/README.md @@ -0,0 +1,121 @@ + + +# enum2str + +> Return the BLAS operation side string associated with a BLAS operation side enumeration constant. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var enum2str = require( '@stdlib/blas/base/operation-side-enum2str' ); +``` + +#### enum2str( operation ) + +Returns the BLAS operation side string associated with a BLAS operation side enumeration constant. + +```javascript +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); + +var v = str2enum( 'left' ); +// returns + +var s = enum2str( v ); +// returns 'left' +``` + +If unable to resolve an operation string, the function returns `null`. + +```javascript +var v = enum2str( -999999999 ); +// returns null +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var enum2str = require( '@stdlib/blas/base/operation-side-enum2str' ); + +var str = enum2str( str2enum( 'left' ) ); +// returns 'left' + +str = enum2str( str2enum( 'right' ) ); +// returns 'right' +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/benchmark/benchmark.js new file mode 100644 index 000000000000..fde2a81be901 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/benchmark/benchmark.js @@ -0,0 +1,55 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var pkg = require( './../package.json' ).name; +var enum2str = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var i; + + values = [ + str2enum( 'left' ), + str2enum( 'right' ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = enum2str( values[ i%values.length ] ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/docs/repl.txt new file mode 100644 index 000000000000..a9e6a0ef3ceb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/docs/repl.txt @@ -0,0 +1,23 @@ + +{{alias}}( operation ) + Returns the BLAS operation side string associated with a BLAS operation + side enumeration constant. + + Parameters + ---------- + operation: integer + Operation enumeration constant. + + Returns + ------- + out: string|null + Operation string. + + Examples + -------- + > var out = {{alias}}( {{alias:@stdlib/blas/base/operation-side-str2enum}}( 'left' ) ) + 'left' + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/docs/types/index.d.ts new file mode 100644 index 000000000000..b2fd02fdba47 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/docs/types/index.d.ts @@ -0,0 +1,41 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns the BLAS operation side string associated with a BLAS operation side enumeration constant. +* +* @param operation - enumeration constant +* @returns operation string +* +* @example +* var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +* +* var v = str2enum( 'left' ); +* // returns +* +* var s = enum2str( v ); +* // returns 'left' +*/ +declare function enum2str( operation: number ): string | null; + + +// EXPORTS // + +export = enum2str; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/docs/types/test.ts new file mode 100644 index 000000000000..65833e5930c3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/docs/types/test.ts @@ -0,0 +1,39 @@ +/* +* @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. +*/ + +import enum2str = require( './index' ); + + +// TESTS // + +// The function returns a string or null... +{ + enum2str( 0 ); // $ExpectType string | null +} + +// The compiler throws an error if not provided a number... +{ + enum2str( '10' ); // $ExpectError + enum2str( true ); // $ExpectError + enum2str( false ); // $ExpectError + enum2str( null ); // $ExpectError + enum2str( undefined ); // $ExpectError + enum2str( [] ); // $ExpectError + enum2str( {} ); // $ExpectError + enum2str( ( x: number ): number => x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/examples/index.js b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/examples/index.js new file mode 100644 index 000000000000..c71494d73194 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/examples/index.js @@ -0,0 +1,30 @@ +/** +* @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'; + +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var enum2str = require( './../lib' ); + +var str = enum2str( str2enum( 'left' ) ); +console.log( str ); +// => 'left' + +str = enum2str( str2enum( 'right' ) ); +console.log( str ); +// => 'right' diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/lib/index.js b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/lib/index.js new file mode 100644 index 000000000000..987294de454f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/lib/index.js @@ -0,0 +1,44 @@ +/** +* @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'; + +/** +* Return the BLAS operation side string associated with a BLAS operation side enumeration constant. +* +* @module @stdlib/blas/base/operation-side-enum2str +* +* @example +* var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +* var enum2str = require( '@stdlib/blas/base/operation-side-enum2str' ); +* +* var v = str2enum( 'left' ); +* // returns +* +* var s = enum2str( v ); +* // returns 'left' +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/lib/main.js b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/lib/main.js new file mode 100644 index 000000000000..ad8c4f01ecf9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/lib/main.js @@ -0,0 +1,59 @@ +/** +* @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 objectInverse = require( '@stdlib/utils/object-inverse' ); +var enumeration = require( '@stdlib/blas/base/operation-sides' ).enum; + + +// VARIABLES // + +var hash = objectInverse( enumeration(), { + 'duplicates': false +}); + + +// MAIN // + +/** +* Returns the BLAS operation side string associated with a BLAS operation side enumeration constant. +* +* @param {integer} operation - operation enumeration constant +* @returns {(string|null)} operation string or null +* +* @example +* var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +* +* var v = str2enum( 'left' ); +* // returns +* +* var s = enum2str( v ); +* // returns 'left' +*/ +function enum2str( operation ) { + var v = hash[ operation ]; + return ( typeof v === 'string' ) ? v : null; // note: we include this guard to prevent walking the prototype chain +} + + +// EXPORTS // + +module.exports = enum2str; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/package.json b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/package.json new file mode 100644 index 000000000000..7833774d2d87 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/blas/base/operation-side-enum2str", + "version": "0.0.0", + "description": "Return the BLAS operation side string associated with a BLAS operation side enumeration constant.", + "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": [ + "stdlib", + "blas", + "ndarray", + "matrix", + "operation", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "enum" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/test/test.js b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/test/test.js new file mode 100644 index 000000000000..c648fd0b87c8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-enum2str/test/test.js @@ -0,0 +1,65 @@ +/** +* @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 tape = require( 'tape' ); +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var enum2str = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'right', + 'left' +]; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof enum2str, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the operation string associated with a BLAS operation side enumeration constant', function test( t ) { + var i; + for ( i = 0; i < VALUES.length; i++ ) { + t.strictEqual( enum2str( str2enum( VALUES[ i ] ) ), VALUES[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns `null` if unable to resolve an operation string', function test( t ) { + var values; + var i; + + values = [ + -9999999, + -999999999, + -99999999999 + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( enum2str( values[ i ] ), null, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/README.md b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/README.md new file mode 100644 index 000000000000..0b01668fb230 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/README.md @@ -0,0 +1,124 @@ + + +# resolve + +> Return the enumeration constant associated with a supported BLAS operation side value. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var resolve = require( '@stdlib/blas/base/operation-side-resolve-enum' ); +``` + +#### resolve( operation ) + +Returns the enumeration constant associated with a BLAS operation side value. + +```javascript +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); + +var v = resolve( 'right' ); +// returns + +v = resolve( str2enum( 'right' ) ); +// returns +``` + +If unable to resolve an enumeration constant, the function returns `null`. + +```javascript +var v = resolve( 'beep' ); +// returns null +``` + +
+ + + + + +
+ +## Notes + +- Downstream consumers of this function should **not** rely on specific integer values (e.g., `LEFT == 0`). Instead, the function should be used in an opaque manner. + +
+ + + + + +
+ +## Examples + + + +```javascript +var resolve = require( '@stdlib/blas/base/operation-side-resolve-enum' ); + +var v = resolve( 'right' ); +// returns + +v = resolve( 'left' ); +// returns +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/benchmark/benchmark.js new file mode 100644 index 000000000000..ed9ce0b67047 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/benchmark/benchmark.js @@ -0,0 +1,80 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var pkg = require( './../package.json' ).name; +var resolve = require( './../lib' ); + + +// MAIN // + +bench( pkg+'::string', function benchmark( b ) { + var values; + var out; + var i; + + values = [ + 'right', + 'left' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = resolve( values[ i%values.length ] ); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( !isInteger( out ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::integer', function benchmark( b ) { + var values; + var out; + var i; + + values = [ + str2enum( 'right' ), + str2enum( 'left' ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = resolve( values[ i%values.length ] ); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( !isInteger( out ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/docs/repl.txt new file mode 100644 index 000000000000..7681970715e6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/docs/repl.txt @@ -0,0 +1,29 @@ + +{{alias}}( operation ) + Returns the enumeration constant associated with a supported BLAS operation + side value. + + Downstream consumers of this function should *not* rely on specific integer + values (e.g., `LEFT == 0`). Instead, the function should be used in an + opaque manner. + + Parameters + ---------- + operation: any + Operation value. + + Returns + ------- + out: integer|null + Enumeration constant. + + Examples + -------- + > var out = {{alias}}( 'right' ) + + > out = {{alias}}( {{alias:@stdlib/blas/base/operation-side-str2enum}}( 'right' ) ) + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/docs/types/index.d.ts new file mode 100644 index 000000000000..12efc0dcf74f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/docs/types/index.d.ts @@ -0,0 +1,40 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns the enumeration constant associated with a BLAS operation side value. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `LEFT == 0`). Instead, the function should be used in an opaque manner. +* +* @param operation - operation value +* @returns enumeration constant +* +* @example +* var v = resolve( 'right' ); +* // returns +*/ +declare function resolve( operation: any ): number | null; + + +// EXPORTS // + +export = resolve; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/docs/types/test.ts new file mode 100644 index 000000000000..b7240d4b83f3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/docs/types/test.ts @@ -0,0 +1,28 @@ +/* +* @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. +*/ + +import resolve = require( './index' ); + + +// TESTS // + +// The function returns a number or null... +{ + resolve( 0 ); // $ExpectType number | null + resolve( 'right' ); // $ExpectType number | null +} diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/examples/index.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/examples/index.js new file mode 100644 index 000000000000..a9d51a1a5426 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/examples/index.js @@ -0,0 +1,29 @@ +/** +* @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'; + +var resolve = require( './../lib' ); + +var v = resolve( 'right' ); +console.log( v ); +// => + +v = resolve( 'left' ); +console.log( v ); +// => diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/lib/index.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/lib/index.js new file mode 100644 index 000000000000..53e992b147a7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/lib/index.js @@ -0,0 +1,40 @@ +/** +* @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'; + +/** +* Return the enumeration constant associated with a supported BLAS operation side value. +* +* @module @stdlib/blas/base/operation-side-resolve-enum +* +* @example +* var resolve = require( '@stdlib/blas/base/operation-side-resolve-enum' ); +* +* var v = resolve( 'right' ); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/lib/main.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/lib/main.js new file mode 100644 index 000000000000..36a2024c650e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/lib/main.js @@ -0,0 +1,57 @@ +/** +* @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 enum2str = require( '@stdlib/blas/base/operation-side-enum2str' ); +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); + + +// MAIN // + +/** +* Returns the enumeration constant associated with a supported BLAS operation side value. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `LEFT == 0`). Instead, the function should be used in an opaque manner. +* +* @param {*} operation - operation value +* @returns {(integer|null)} enumeration constant or null +* +* @example +* var v = resolve( 'right' ); +* // returns +*/ +function resolve( operation ) { + var t = ( typeof operation ); + if ( t === 'number' ) { + return ( enum2str( operation ) ) ? operation : null; + } + if ( t === 'string' ) { + return str2enum( operation ); + } + return null; +} + + +// EXPORTS // + +module.exports = resolve; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/package.json b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/package.json new file mode 100644 index 000000000000..86acfdc8d7c9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/blas/base/operation-side-resolve-enum", + "version": "0.0.0", + "description": "Return the enumeration constant associated with a supported BLAS operation side value.", + "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": [ + "stdlib", + "blas", + "ndarray", + "matrix", + "operation", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "enum" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/test/test.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/test/test.js new file mode 100644 index 000000000000..9dcf2021c845 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-enum/test/test.js @@ -0,0 +1,74 @@ +/** +* @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 tape = require( 'tape' ); +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var resolve = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'left', + 'right' +]; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof resolve, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the enumeration constant associated with a BLAS operation side value', function test( t ) { + var v; + var i; + for ( i = 0; i < VALUES.length; i++ ) { + v = str2enum( VALUES[ i ] ); + t.strictEqual( resolve( VALUES[ i ] ), v, 'returns expected value' ); + t.strictEqual( resolve( v ), v, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns `null` if unable to resolve an enumeration constant', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'foo', + 'bar', + -99999999, + -9999999999, + -9999999999999, + true, + false + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( resolve( values[ i ] ), null, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/README.md b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/README.md new file mode 100644 index 000000000000..848d6d5e7e1f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/README.md @@ -0,0 +1,121 @@ + + +# resolve + +> Return the operation side string associated with a supported BLAS operation side value. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var resolve = require( '@stdlib/blas/base/operation-side-resolve-str' ); +``` + +#### resolve( operation ) + +Returns the operation side string associated with a BLAS operation side value. + +```javascript +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); + +var v = resolve( 'left' ); +// returns 'left' + +v = resolve( str2enum( 'left' ) ); +// returns 'left' +``` + +If unable to resolve a operation side string, the function returns `null`. + +```javascript +var v = resolve( 'beep' ); +// returns null +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var resolve = require( '@stdlib/blas/base/operation-side-resolve-str' ); + +var v = resolve( str2enum( 'left' ) ); +// returns 'left' + +v = resolve( str2enum( 'right' ) ); +// returns 'right' +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/benchmark/benchmark.js new file mode 100644 index 000000000000..9ecb5bf480b4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/benchmark/benchmark.js @@ -0,0 +1,80 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var pkg = require( './../package.json' ).name; +var resolve = require( './../lib' ); + + +// MAIN // + +bench( pkg+'::string', function benchmark( b ) { + var values; + var out; + var i; + + values = [ + 'left', + 'right' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = resolve( values[ i%values.length ] ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::integer', function benchmark( b ) { + var values; + var out; + var i; + + values = [ + str2enum( 'left' ), + str2enum( 'right' ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = resolve( values[ i%values.length ] ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/docs/repl.txt new file mode 100644 index 000000000000..c3958a6228b5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/docs/repl.txt @@ -0,0 +1,25 @@ + +{{alias}}( operation ) + Returns the operation side string associated with a supported BLAS operation + side value. + + Parameters + ---------- + operation: any + Operation value. + + Returns + ------- + out: string|null + Operation string. + + Examples + -------- + > var out = {{alias}}( 'left' ) + 'left' + > out = {{alias}}( {{alias:@stdlib/blas/base/operation-side-str2enum}}( 'left' ) ) + 'left' + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/docs/types/index.d.ts new file mode 100644 index 000000000000..b2143d445323 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/docs/types/index.d.ts @@ -0,0 +1,38 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns the operation side string associated with a BLAS operation side value. +* +* @param operation - operation value +* @returns operation side string +* +* @example +* var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +* +* var v = resolve( str2enum( 'left' ) ); +* // returns 'left' +*/ +declare function resolve( operation: any ): string | null; + + +// EXPORTS // + +export = resolve; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/docs/types/test.ts new file mode 100644 index 000000000000..392709cd4c5a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/docs/types/test.ts @@ -0,0 +1,28 @@ +/* +* @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. +*/ + +import resolve = require( './index' ); + + +// TESTS // + +// The function returns a string or null... +{ + resolve( 0 ); // $ExpectType string | null + resolve( 'left' ); // $ExpectType string | null +} diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/examples/index.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/examples/index.js new file mode 100644 index 000000000000..50513b960b3a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/examples/index.js @@ -0,0 +1,30 @@ +/** +* @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'; + +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var resolve = require( './../lib' ); + +var v = resolve( str2enum( 'left' ) ); +console.log( v ); +// => 'left' + +v = resolve( str2enum( 'right' ) ); +console.log( v ); +// => 'right' diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/lib/index.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/lib/index.js new file mode 100644 index 000000000000..240bb256dbb3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/lib/index.js @@ -0,0 +1,41 @@ +/** +* @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'; + +/** +* Return the operation side string associated with a supported BLAS operation side value. +* +* @module @stdlib/blas/base/operation-side-resolve-str +* +* @example +* var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +* var resolve = require( '@stdlib/blas/base/operation-side-resolve-str' ); +* +* var v = resolve( str2enum( 'left' ) ); +* // returns 'left' +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/lib/main.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/lib/main.js new file mode 100644 index 000000000000..fe66e856b34c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/lib/main.js @@ -0,0 +1,55 @@ +/** +* @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 enum2str = require( '@stdlib/blas/base/operation-side-enum2str' ); +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); + + +// MAIN // + +/** +* Returns the operation side string associated with a supported BLAS operation side value. +* +* @param {*} operation - operation value +* @returns {(string|null)} operation side string or null +* +* @example +* var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +* +* var v = resolve( str2enum( 'left' ) ); +* // returns 'left' +*/ +function resolve( operation ) { + var t = ( typeof operation ); + if ( t === 'string' ) { + return ( str2enum( operation ) === null ) ? null : operation; + } + if ( t === 'number' ) { + return enum2str( operation ); + } + return null; +} + + +// EXPORTS // + +module.exports = resolve; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/package.json b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/package.json new file mode 100644 index 000000000000..f5f718fdec31 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/blas/base/operation-side-resolve-str", + "version": "0.0.0", + "description": "Return the operation side string associated with a supported BLAS operation side value.", + "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": [ + "stdlib", + "blas", + "ndarray", + "matrix", + "operation", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "enum" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/test/test.js b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/test/test.js new file mode 100644 index 000000000000..1257e8578de1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-resolve-str/test/test.js @@ -0,0 +1,74 @@ +/** +* @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 tape = require( 'tape' ); +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +var resolve = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'right', + 'left' +]; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof resolve, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the operation side string associated with a BLAS operation side value', function test( t ) { + var v; + var i; + for ( i = 0; i < VALUES.length; i++ ) { + v = str2enum( VALUES[ i ] ); + t.strictEqual( resolve( VALUES[ i ] ), VALUES[ i ], 'returns expected value' ); + t.strictEqual( resolve( v ), VALUES[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns `null` if unable to resolve a operation side string', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'foo', + 'bar', + -99999999, + -9999999999, + -9999999999999, + true, + false + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( resolve( values[ i ] ), null, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/README.md b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/README.md new file mode 100644 index 000000000000..771c920ec8a6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/README.md @@ -0,0 +1,119 @@ + + +# str2enum + +> Return the enumeration constant associated with a BLAS operation side. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +``` + +#### str2enum( operation ) + +Return the enumeration constant associated with a BLAS operation side. + +```javascript +var v = str2enum( 'left' ); +// returns +``` + +If unable to resolve an enumeration constant, the function returns `null`. + +```javascript +var v = str2enum( 'beep' ); +// returns null +``` + +
+ + + + + +
+ +## Notes + +- Downstream consumers of this function should **not** rely on specific integer values (e.g., `LEFT == 0`). Instead, the function should be used in an opaque manner. + +
+ + + + + +
+ +## Examples + + + +```javascript +var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); + +var v = str2enum( 'left' ); +// returns + +v = str2enum( 'right' ); +// returns +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/benchmark/benchmark.js new file mode 100644 index 000000000000..4df1a7d425c6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/benchmark/benchmark.js @@ -0,0 +1,54 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var str2enum = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var i; + + values = [ + 'left', + 'right' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = str2enum( values[ i%values.length ] ); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( !isInteger( out ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/docs/repl.txt new file mode 100644 index 000000000000..acff469cc5c2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/docs/repl.txt @@ -0,0 +1,26 @@ + +{{alias}}( operation ) + Returns the enumeration constant associated with a BLAS operation side. + + Downstream consumers of this function should *not* rely on specific integer + values (e.g., `LEFT == 0`). Instead, the function should be used in an + opaque manner. + + Parameters + ---------- + operation: string + Operation side. + + Returns + ------- + out: integer|null + Enumeration constant. + + Examples + -------- + > var out = {{alias}}( 'left' ) + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/docs/types/index.d.ts new file mode 100644 index 000000000000..9f466a872b11 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/docs/types/index.d.ts @@ -0,0 +1,40 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns the enumeration constant associated with a BLAS operation side. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `LEFT == 0`). Instead, the function should be used in an opaque manner. +* +* @param operation - operation side +* @returns enumeration constant +* +* @example +* var v = str2enum( 'left' ); +* // returns +*/ +declare function str2enum( operation: string ): number | null; + + +// EXPORTS // + +export = str2enum; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/docs/types/test.ts new file mode 100644 index 000000000000..7e00b5288065 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/docs/types/test.ts @@ -0,0 +1,39 @@ +/* +* @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. +*/ + +import str2enum = require( './index' ); + + +// TESTS // + +// The function returns a number or null... +{ + str2enum( 'left' ); // $ExpectType number | null +} + +// The compiler throws an error if not provided a string... +{ + str2enum( 10 ); // $ExpectError + str2enum( true ); // $ExpectError + str2enum( false ); // $ExpectError + str2enum( null ); // $ExpectError + str2enum( undefined ); // $ExpectError + str2enum( [] ); // $ExpectError + str2enum( {} ); // $ExpectError + str2enum( ( x: number ): number => x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/examples/index.js b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/examples/index.js new file mode 100644 index 000000000000..23529d936330 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/examples/index.js @@ -0,0 +1,29 @@ +/** +* @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'; + +var str2enum = require( './../lib' ); + +var v = str2enum( 'left' ); +console.log( v ); +// => + +v = str2enum( 'right' ); +console.log( v ); +// => diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/lib/index.js b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/lib/index.js new file mode 100644 index 000000000000..06e9af76ca7b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/lib/index.js @@ -0,0 +1,40 @@ +/** +* @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'; + +/** +* Return the enumeration constant associated with a BLAS operation side. +* +* @module @stdlib/blas/base/operation-side-str2enum +* +* @example +* var str2enum = require( '@stdlib/blas/base/operation-side-str2enum' ); +* +* var v = str2enum( 'left' ); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/lib/main.js b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/lib/main.js new file mode 100644 index 000000000000..1380466cc4a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/lib/main.js @@ -0,0 +1,55 @@ +/** +* @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 enumeration = require( '@stdlib/blas/base/operation-sides' ).enum; + + +// VARIABLES // + +var ENUM = enumeration(); + + +// MAIN // + +/** +* Returns the enumeration constant associated with a BLAS operation side. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `LEFT == 0`). Instead, the function should be used in an opaque manner. +* +* @param {string} operation - operation side +* @returns {(integer|null)} integer value or null +* +* @example +* var v = str2enum( 'left' ); +* // returns +*/ +function str2enum( operation ) { + var v = ENUM[ operation ]; + return ( typeof v === 'number' ) ? v : null; // note: we include this guard to prevent walking the prototype chain +} + + +// EXPORTS // + +module.exports = str2enum; diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/package.json b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/package.json new file mode 100644 index 000000000000..7bef247ca423 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/blas/base/operation-side-str2enum", + "version": "0.0.0", + "description": "Return the enumeration constant associated with a BLAS operation side.", + "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": [ + "stdlib", + "blas", + "ndarray", + "matrix", + "operation", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "enum" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/test/test.js b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/test/test.js new file mode 100644 index 000000000000..16732bea1dd9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/operation-side-str2enum/test/test.js @@ -0,0 +1,66 @@ +/** +* @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 tape = require( 'tape' ); +var enum2str = require( '@stdlib/blas/base/operation-side-enum2str' ); +var str2enum = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'left', + 'right' +]; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof str2enum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the enumeration constant associated with a string', function test( t ) { + var i; + for ( i = 0; i < VALUES.length; i++ ) { + t.strictEqual( enum2str( str2enum( VALUES[ i ] ) ), VALUES[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns `null` if unable to resolve an enumeration constant', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'foo', + 'bar' + ]; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( str2enum( values[ i ] ), null, 'returns expected value' ); + } + t.end(); +});