From 02e19dd2fdc09487fb4ed6b3c20c833798b3dcd1 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:01:12 +0530 Subject: [PATCH 01/13] chore: add readme --- .../base/matrix-triangle-enum2str/README.md | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/README.md diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/README.md b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/README.md new file mode 100644 index 000000000000..a5d170e7f3d0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/README.md @@ -0,0 +1,121 @@ + + +# enum2str + +> Return the BLAS matrix triangle string associated with a BLAS matrix triangle enumeration constant. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var enum2str = require( '@stdlib/blas/base/matrix-triangle-enum2str' ); +``` + +#### enum2str( operation ) + +Returns the BLAS matrix triangle string associated with a BLAS matrix triangle enumeration constant. + +```javascript +var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); + +var v = str2enum( 'upper' ); +// returns + +var s = enum2str( v ); +// returns 'upper' +``` + +If unable to resolve a operation string, the function returns `null`. + +```javascript +var v = enum2str( -999999999 ); +// returns null +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +var enum2str = require( '@stdlib/blas/base/matrix-triangle-enum2str' ); + +var str = enum2str( str2enum( 'upper' ) ); +// returns 'upper' + +str = enum2str( str2enum( 'lower' ) ); +// returns 'lower' +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + From 2dbe6aacbf644e6dd83f50fd3b1d75b8055c6085 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:02:04 +0530 Subject: [PATCH 02/13] chore: add benchmark --- .../benchmark/benchmark.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/benchmark/benchmark.js diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/benchmark/benchmark.js new file mode 100644 index 000000000000..9b78f64697b3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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/matrix-triangle-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( 'upper' ), + str2enum( 'lower' ) + ]; + + 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(); +}); From d0f8378f1e4fe9053f51df0cb5c22184954c17c3 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:03:43 +0530 Subject: [PATCH 03/13] chore: add examples --- .../examples/index.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/examples/index.js diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/examples/index.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/examples/index.js new file mode 100644 index 000000000000..9e49329541c1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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/matrix-triangle-str2enum' ); +var enum2str = require( './../lib' ); + +var str = enum2str( str2enum( 'upper' ) ); +console.log( str ); +// => 'upper' + +str = enum2str( str2enum( 'lower' ) ); +console.log( str ); +// => 'lower' From 49879f784622a9c2401e26633f0961a54f228e01 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:03:57 +0530 Subject: [PATCH 04/13] chore: add lib --- .../matrix-triangle-enum2str/lib/index.js | 44 ++++++++++++++ .../base/matrix-triangle-enum2str/lib/main.js | 59 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/main.js diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/index.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/index.js new file mode 100644 index 000000000000..78b5063114e1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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 matrix triangle string associated with a BLAS matrix triangle enumeration constant. +* +* @module @stdlib/blas/base/matrix-triangle-enum2str +* +* @example +* var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +* var enum2str = require( '@stdlib/blas/base/matrix-triangle-enum2str' ); +* +* var v = str2enum( 'upper' ); +* // returns +* +* var s = enum2str( v ); +* // returns 'upper' +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/main.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/main.js new file mode 100644 index 000000000000..3781539fd140 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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/matrix-triangles' ).enum; + + +// VARIABLES // + +var hash = objectInverse( enumeration(), { + 'duplicates': false +}); + + +// MAIN // + +/** +* Returns the BLAS matrix triangle string associated with a BLAS matrix triangle enumeration constant. +* +* @param {integer} operation - operation enumeration constant +* @returns {(string|null)} operation string or null +* +* @example +* var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +* +* var v = str2enum( 'upper' ); +* // returns +* +* var s = enum2str( v ); +* // returns 'upper' +*/ +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; From 3aadae01a5f2f16ceae57faaa346e2eca436197c Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:04:15 +0530 Subject: [PATCH 05/13] chore: add package.json --- .../matrix-triangle-enum2str/package.json | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/package.json diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/package.json b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/package.json new file mode 100644 index 000000000000..e55cba29fd0b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/matrix-triangle-enum2str", + "version": "0.0.0", + "description": "Return the BLAS matrix triangle string associated with a BLAS matrix triangle 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", + "stdtypes", + "types", + "blas", + "triangle", + "triangular", + "matrix", + "multidimensional", + "ndarray", + "array", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} From 25eef14014243a093d415e916c078f8ec68bf872 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:04:29 +0530 Subject: [PATCH 06/13] chore: add test --- .../matrix-triangle-enum2str/test/test.js | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/test/test.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/test/test.js new file mode 100644 index 000000000000..81b66af36ad3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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/matrix-triangle-str2enum' ); +var enum2str = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'lower', + 'upper' +]; + + +// 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 matrix triangle 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 a 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(); +}); From 68659cbf523ce8e48ecb49894c4a976044db5de6 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:05:47 +0530 Subject: [PATCH 07/13] chore: add docs/types --- .../docs/types/index.d.ts | 41 +++++++++++++++++++ .../docs/types/test.ts | 39 ++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/index.d.ts new file mode 100644 index 000000000000..16a55119c52e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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 matrix triangle string associated with a BLAS matrix triangle enumeration constant. +* +* @param operation - enumeration constant +* @returns operation string +* +* @example +* var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +* +* var v = str2enum( 'upper' ); +* // returns +* +* var s = enum2str( v ); +* // returns 'upper' +*/ +declare function enum2str( operation: number ): string | null; + + +// EXPORTS // + +export = enum2str; diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/test.ts new file mode 100644 index 000000000000..65833e5930c3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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 +} From 421305a5c88f5deb559f1cb986638bf665e0c4f7 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:06:33 +0530 Subject: [PATCH 08/13] chore: add docs/repl.txt --- .../matrix-triangle-enum2str/docs/repl.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt new file mode 100644 index 000000000000..92b08cc1d233 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt @@ -0,0 +1,22 @@ + +{{alias}}( operation ) + Returns the BLAS matrix triangle string associated with a BLAS transpose + operation enumeration constant. + + Parameters + ---------- + operation: integer + Operation enumeration constant. + + Returns + ------- + out: string|null + Operation string. + + Examples + -------- + > var out = {{alias}}( {{alias:@stdlib/blas/base/matrix-triangle-str2enum}}( 'upper' ) ) + 'upper' + + See Also + -------- From 75294fa956112c554138aef957b72a8ef290325c Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:06:50 +0530 Subject: [PATCH 09/13] feat: add matrix-triangle-str2enum --- .../base/matrix-triangle-str2enum/README.md | 119 ++++++++++++++++++ .../benchmark/benchmark.js | 54 ++++++++ .../matrix-triangle-str2enum/docs/repl.txt | 25 ++++ .../docs/types/index.d.ts | 40 ++++++ .../docs/types/test.ts | 39 ++++++ .../examples/index.js | 29 +++++ .../matrix-triangle-str2enum/lib/index.js | 40 ++++++ .../base/matrix-triangle-str2enum/lib/main.js | 55 ++++++++ .../matrix-triangle-str2enum/package.json | 68 ++++++++++ .../matrix-triangle-str2enum/test/test.js | 66 ++++++++++ 10 files changed, 535 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/README.md b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/README.md new file mode 100644 index 000000000000..f42e6368df65 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/README.md @@ -0,0 +1,119 @@ + + +# str2enum + +> Return the enumeration constant associated with a BLAS matrix triangle. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +``` + +#### str2enum( operation ) + +Return the enumeration constant associated with a BLAS matrix triangle. + +```javascript +var v = str2enum( 'upper' ); +// 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., `UPPER == 0`). Instead, the function should be used in an opaque manner. + +
+ + + + + +
+ +## Examples + + + +```javascript +var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); + +var v = str2enum( 'upper' ); +// returns + +v = str2enum( 'lower' ); +// returns +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/benchmark/benchmark.js new file mode 100644 index 000000000000..e2200bbcd3cc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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 = [ + 'upper', + 'lower' + ]; + + 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/matrix-triangle-str2enum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/repl.txt new file mode 100644 index 000000000000..0165e8294d3e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/repl.txt @@ -0,0 +1,25 @@ + +{{alias}}( operation ) + Returns the enumeration constant associated with a BLAS matrix triangle. + + Downstream consumers of this function should *not* rely on specific integer + values (e.g., `UPPER == 0`). Instead, the function should be used in an + opaque manner. + + Parameters + ---------- + operation: string + Matrix triangle. + + Returns + ------- + out: integer|null + Enumeration constant. + + Examples + -------- + > var out = {{alias}}( 'upper' ) + + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/index.d.ts new file mode 100644 index 000000000000..9d1d5d0022ed --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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 matrix triangle. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UPPER == 0`). Instead, the function should be used in an opaque manner. +* +* @param operation - matrix triangle +* @returns enumeration constant +* +* @example +* var v = str2enum( 'upper' ); +* // returns +*/ +declare function str2enum( operation: string ): number | null; + + +// EXPORTS // + +export = str2enum; diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/test.ts new file mode 100644 index 000000000000..f61d5962d701 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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( 'upper' ); // $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/matrix-triangle-str2enum/examples/index.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/examples/index.js new file mode 100644 index 000000000000..7c611888b96f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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( 'upper' ); +console.log( v ); +// => + +v = str2enum( 'lower' ); +console.log( v ); +// => diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/index.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/index.js new file mode 100644 index 000000000000..e62510df532b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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 matrix triangle. +* +* @module @stdlib/blas/base/matrix-triangle-str2enum +* +* @example +* var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +* +* var v = str2enum( 'upper' ); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/main.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/main.js new file mode 100644 index 000000000000..604b07b5bfe9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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/matrix-triangles' ).enum; + + +// VARIABLES // + +var ENUM = enumeration(); + + +// MAIN // + +/** +* Returns the enumeration constant associated with a BLAS matrix triangle. +* +* ## Notes +* +* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UPPER == 0`). Instead, the function should be used in an opaque manner. +* +* @param {string} operation - matrix triangle +* @returns {(integer|null)} integer value or null +* +* @example +* var v = str2enum( 'upper' ); +* // 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/matrix-triangle-str2enum/package.json b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/package.json new file mode 100644 index 000000000000..b8d2495baaed --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/matrix-triangle-str2enum", + "version": "0.0.0", + "description": "Return the enumeration constant associated with a BLAS matrix triangle.", + "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", + "stdtypes", + "types", + "blas", + "triangle", + "triangular", + "matrix", + "multidimensional", + "ndarray", + "array", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/test/test.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/test/test.js new file mode 100644 index 000000000000..cbc3d3ac3c8e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-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/matrix-triangle-enum2str' ); +var str2enum = require( './../lib' ); + + +// VARIABLES // + +var VALUES = [ + 'upper', + 'lower' +]; + + +// 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(); +}); From 05e1fdcb24c6ed7a5430997fe344caeee463e250 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 15:20:26 +0530 Subject: [PATCH 10/13] chore: update repl.txt --- .../@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt index 92b08cc1d233..7334cf7281b9 100644 --- a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( operation ) - Returns the BLAS matrix triangle string associated with a BLAS transpose - operation enumeration constant. + Returns the BLAS matrix triangle string associated with a BLAS matrix + triangle enumeration constant. Parameters ---------- From 5bec3a7aef77bdb49b391ff8437303a51de46011 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Jul 2024 02:54:58 -0700 Subject: [PATCH 11/13] refactor: rename parameter --- .../base/matrix-triangle-enum2str/docs/types/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/index.d.ts index 16a55119c52e..0efab6852a36 100644 --- a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/types/index.d.ts @@ -21,8 +21,8 @@ /** * Returns the BLAS matrix triangle string associated with a BLAS matrix triangle enumeration constant. * -* @param operation - enumeration constant -* @returns operation string +* @param value - enumeration constant +* @returns matrix triangle string * * @example * var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); @@ -33,7 +33,7 @@ * var s = enum2str( v ); * // returns 'upper' */ -declare function enum2str( operation: number ): string | null; +declare function enum2str( value: number ): string | null; // EXPORTS // From 8ebd2df16122a500e290226cd58e94d05193f273 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Jul 2024 02:59:18 -0700 Subject: [PATCH 12/13] refactor: rename parameter --- .../@stdlib/blas/base/matrix-triangle-enum2str/README.md | 4 ++-- .../blas/base/matrix-triangle-enum2str/docs/repl.txt | 8 ++++---- .../blas/base/matrix-triangle-enum2str/lib/main.js | 8 ++++---- .../blas/base/matrix-triangle-enum2str/test/test.js | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/README.md b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/README.md index a5d170e7f3d0..cc5250f6d045 100644 --- a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/README.md +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/README.md @@ -40,7 +40,7 @@ limitations under the License. var enum2str = require( '@stdlib/blas/base/matrix-triangle-enum2str' ); ``` -#### enum2str( operation ) +#### enum2str( value ) Returns the BLAS matrix triangle string associated with a BLAS matrix triangle enumeration constant. @@ -54,7 +54,7 @@ var s = enum2str( v ); // returns 'upper' ``` -If unable to resolve a operation string, the function returns `null`. +If unable to resolve a matrix triangle string, the function returns `null`. ```javascript var v = enum2str( -999999999 ); diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt index 7334cf7281b9..c21f6594c985 100644 --- a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/docs/repl.txt @@ -1,17 +1,17 @@ -{{alias}}( operation ) +{{alias}}( value ) Returns the BLAS matrix triangle string associated with a BLAS matrix triangle enumeration constant. Parameters ---------- - operation: integer - Operation enumeration constant. + value: integer + Matrix triangle enumeration constant. Returns ------- out: string|null - Operation string. + Matrix triangle string. Examples -------- diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/main.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/main.js index 3781539fd140..15e05e7eaad2 100644 --- a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/lib/main.js @@ -36,8 +36,8 @@ var hash = objectInverse( enumeration(), { /** * Returns the BLAS matrix triangle string associated with a BLAS matrix triangle enumeration constant. * -* @param {integer} operation - operation enumeration constant -* @returns {(string|null)} operation string or null +* @param {integer} value - enumeration constant +* @returns {(string|null)} matrix triangle string or null * * @example * var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); @@ -48,8 +48,8 @@ var hash = objectInverse( enumeration(), { * var s = enum2str( v ); * // returns 'upper' */ -function enum2str( operation ) { - var v = hash[ operation ]; +function enum2str( value ) { + var v = hash[ value ]; return ( typeof v === 'string' ) ? v : null; // note: we include this guard to prevent walking the prototype chain } diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/test/test.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/test/test.js index 81b66af36ad3..da6b9a4c47ef 100644 --- a/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-enum2str/test/test.js @@ -41,7 +41,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns the operation string associated with a BLAS matrix triangle enumeration constant', function test( t ) { +tape( 'the function returns the string associated with a BLAS matrix triangle 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' ); @@ -49,7 +49,7 @@ tape( 'the function returns the operation string associated with a BLAS matrix t t.end(); }); -tape( 'the function returns `null` if unable to resolve a operation string', function test( t ) { +tape( 'the function returns `null` if unable to resolve a string', function test( t ) { var values; var i; From 3287f58e017d200f659e1fd4048b7202271c912e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Jul 2024 03:01:48 -0700 Subject: [PATCH 13/13] refactor: rename parameter --- .../blas/base/matrix-triangle-str2enum/docs/repl.txt | 6 +++--- .../base/matrix-triangle-str2enum/docs/types/index.d.ts | 4 ++-- .../@stdlib/blas/base/matrix-triangle-str2enum/lib/main.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/repl.txt index 0165e8294d3e..ce8b19a42910 100644 --- a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( operation ) +{{alias}}( value ) Returns the enumeration constant associated with a BLAS matrix triangle. Downstream consumers of this function should *not* rely on specific integer @@ -8,8 +8,8 @@ Parameters ---------- - operation: string - Matrix triangle. + value: string + Matrix triangle string. Returns ------- diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/index.d.ts index 9d1d5d0022ed..acb58893be17 100644 --- a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/docs/types/index.d.ts @@ -25,14 +25,14 @@ * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UPPER == 0`). Instead, the function should be used in an opaque manner. * -* @param operation - matrix triangle +* @param value - matrix triangle string * @returns enumeration constant * * @example * var v = str2enum( 'upper' ); * // returns */ -declare function str2enum( operation: string ): number | null; +declare function str2enum( value: string ): number | null; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/main.js b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/main.js index 604b07b5bfe9..bd732b4e5aff 100644 --- a/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/matrix-triangle-str2enum/lib/main.js @@ -37,15 +37,15 @@ var ENUM = enumeration(); * * - Downstream consumers of this function should **not** rely on specific integer values (e.g., `UPPER == 0`). Instead, the function should be used in an opaque manner. * -* @param {string} operation - matrix triangle +* @param {string} value - matrix triangle string * @returns {(integer|null)} integer value or null * * @example * var v = str2enum( 'upper' ); * // returns */ -function str2enum( operation ) { - var v = ENUM[ operation ]; +function str2enum( value ) { + var v = ENUM[ value ]; return ( typeof v === 'number' ) ? v : null; // note: we include this guard to prevent walking the prototype chain }