diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/README.md b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/README.md new file mode 100644 index 000000000000..5c995e23678f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/README.md @@ -0,0 +1,119 @@ + + +# symbols2shorthands + +> Convert an array of symbol [aliases][@stdlib/plot/base/symbol-aliases] and/or [shorthands][@stdlib/plot/base/symbol-shorthands] to [symbol shorthands][@stdlib/plot/base/symbol-shorthands]. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var symbols2shorthands = require( '@stdlib/plot/base/symbols2shorthands' ); +``` + +#### symbols2shorthands( symbols ) + +Converts an array of symbol [aliases][@stdlib/plot/base/symbol-aliases] and/or [shorthands][@stdlib/plot/base/symbol-shorthands] to [symbol shorthands][@stdlib/plot/base/symbol-shorthands]. + +```javascript +var out = symbols2shorthands( [ 'circle', 'square' ] ); +// returns [ 'o', 's' ] +``` + +If unable to resolve a shorthand for an element of the input array, the corresponding element in the output array is `null`. + +```javascript +var out = symbols2shorthands( [ 'circle', 'beep' ] ); +// returns [ 'o', null ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var logEach = require( '@stdlib/console/log-each' ); +var symbolAliases = require( '@stdlib/plot/base/symbol-aliases' ); +var symbols2shorthands = require( '@stdlib/plot/base/symbols2shorthands' ); + +var symbols = symbolAliases(); + +logEach( '%s => %s', symbols, symbols2shorthands( symbols ) ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/benchmark/benchmark.js new file mode 100644 index 000000000000..a390e320dae2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/benchmark/benchmark.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isArray = require( '@stdlib/assert/is-array' ); +var pkg = require( './../package.json' ).name; +var symbols2shorthands = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var i; + + values = [ + [ 'o', '+' ], + [ 'circle', 'triangle-up' ] + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = symbols2shorthands( values[ i%values.length ] ); + if ( out.length !== 2 ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( out ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/docs/repl.txt b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/docs/repl.txt new file mode 100644 index 000000000000..c7ac7b641839 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/docs/repl.txt @@ -0,0 +1,27 @@ + +{{alias}}( symbols ) + Converts an array of symbol aliases and/or shorthands to symbol shorthands. + + If unable to resolve a shorthand for an element of the input array, the + corresponding element in the output array is `null`. + + Parameters + ---------- + symbols: Array + Symbol aliases and/or shorthands. + + Returns + ------- + out: Array + Symbol shorthands. + + Examples + -------- + > var v = {{alias}}( [ 'circle', 'square' ] ) + [ 'o', 's' ] + > v = {{alias}}( [ 'circle', 'beep' ] ) + [ 'o', null ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/docs/types/index.d.ts new file mode 100644 index 000000000000..3feadec3592d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/docs/types/index.d.ts @@ -0,0 +1,47 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 + +/// + +import { Collection } from '@stdlib/types/array'; + +/** +* Converts an array of symbol aliases and/or shorthands to symbol shorthands. +* +* ## Notes +* +* - If unable to resolve a shorthand for an element of the input array, the corresponding element in the output array is `null`. +* +* @param symbols - symbol aliases and/or shorthands +* @returns symbol shorthands +* +* @example +* var v = symbols2shorthands( [ 'circle', 'square' ] ); +* // returns [ 'o', 's' ] +* +* v = symbols2shorthands( [ 'circle', 'beep' ] ); +* // returns [ 'o', null ] +*/ +declare function symbols2shorthands( symbols: Collection ): Array; + + +// EXPORTS // + +export = symbols2shorthands; diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/docs/types/test.ts b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/docs/types/test.ts new file mode 100644 index 000000000000..9c55ab888947 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/docs/types/test.ts @@ -0,0 +1,44 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 symbols2shorthands = require( './index' ); + + +// TESTS // + +// The function returns an array... +{ + symbols2shorthands( [ 'o', '+' ] ); // $ExpectType (string | null)[] +} + +// The compiler throws an error if the function is not provided a collection of strings... +{ + symbols2shorthands( 1 ); // $ExpectError + symbols2shorthands( true ); // $ExpectError + symbols2shorthands( false ); // $ExpectError + symbols2shorthands( null ); // $ExpectError + symbols2shorthands( undefined ); // $ExpectError + symbols2shorthands( {} ); // $ExpectError + symbols2shorthands( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + symbols2shorthands(); // $ExpectError + symbols2shorthands( [ 'o' ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/examples/index.js b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/examples/index.js new file mode 100644 index 000000000000..0566fe2d33f4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/examples/index.js @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 logEach = require( '@stdlib/console/log-each' ); +var symbolAliases = require( '@stdlib/plot/base/symbol-aliases' ); +var symbols2shorthands = require( './../lib' ); + +var symbols = symbolAliases(); + +logEach( '%s => %s', symbols, symbols2shorthands( symbols ) ); diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/lib/index.js b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/lib/index.js new file mode 100644 index 000000000000..5a827428bc35 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/lib/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* Convert an array of symbol aliases and/or shorthands to symbol shorthands. +* +* @module @stdlib/plot/base/symbols2shorthands +* +* @example +* var symbols2shorthands = require( '@stdlib/plot/base/symbols2shorthands' ); +* +* var v = symbols2shorthands( [ 'circle', 'square' ] ); +* // returns [ 'o', 's' ] +* +* v = symbols2shorthands( [ 'circle', 'beep' ] ); +* // returns [ 'o', null ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/lib/main.js b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/lib/main.js new file mode 100644 index 000000000000..b13346ba3335 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/lib/main.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 map = require( '@stdlib/array/base/map' ); +var symbol2shorthand = require( '@stdlib/plot/base/symbol2shorthand' ); + + +// MAIN // + +/** +* Converts an array of symbol aliases and/or shorthands to symbol shorthands. +* +* ## Notes +* +* - If unable to resolve a shorthand for an element of the input array, the corresponding element in the output array is `null`. +* +* @param {Collection} symbols - symbol aliases and/or shorthands +* @returns {Array} symbol shorthands +* +* @example +* var v = symbols2shorthands( [ 'circle', 'square' ] ); +* // returns [ 'o', 's' ] +* +* v = symbols2shorthands( [ 'circle', 'beep' ] ); +* // returns [ 'o', null ] +*/ +function symbols2shorthands( symbols ) { + return map( symbols, symbol2shorthand ); +} + + +// EXPORTS // + +module.exports = symbols2shorthands; diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/package.json b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/package.json new file mode 100644 index 000000000000..8fef69d0dd9e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/plot/base/symbols2shorthands", + "version": "0.0.0", + "description": "Convert an array of symbol aliases and/or shorthands to symbol shorthands.", + "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", + "plot", + "base", + "symbol", + "symbols", + "shorthand", + "shorthands", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/base/symbols2shorthands/test/test.js b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/test/test.js new file mode 100644 index 000000000000..5b23439fe93c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2shorthands/test/test.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var symbolShorthands = require( '@stdlib/plot/base/symbol-shorthands' ); +var symbolAliases = require( '@stdlib/plot/base/symbol-aliases' ); +var symbol2shorthand = require( '@stdlib/plot/base/symbol2shorthand' ); +var symbols2shorthands = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof symbols2shorthands, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function converts an array of symbols to shorthands', function test( t ) { + var expected; + var actual; + var values; + var i; + + values = symbolAliases().concat( symbolShorthands() ); + expected = []; + for ( i = 0; i < values.length; i++ ) { + expected.push( symbol2shorthand( values[ i ] ) ); + } + actual = symbols2shorthands( values ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.strictEqual( isStringArray( actual ), true, 'returns an array of strings' ); + t.end(); +}); + +tape( 'the function returns an empty array if provided an empty array', function test( t ) { + t.deepEqual( symbols2shorthands( [] ), [], 'returns expected value' ); + t.end(); +}); + +tape( 'if unable to resolve a shorthand for an element of the input array, the corresponding element in the output array is `null`', function test( t ) { + var expected; + var actual; + + expected = [ null, 'o', null ]; + actual = symbols2shorthands( [ 'beep', 'o', 'boop' ] ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +});