From e66491c7384790b4d9db5b74af73a4de8fafddb2 Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Fri, 14 Aug 2026 19:52:06 +0530 Subject: [PATCH] feat: add plot/base/symbol2aliases --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../plot/base/symbols2aliases/README.md | 119 ++++++++++++++++++ .../symbols2aliases/benchmark/benchmark.js | 54 ++++++++ .../plot/base/symbols2aliases/docs/repl.txt | 28 +++++ .../symbols2aliases/docs/types/index.d.ts | 47 +++++++ .../base/symbols2aliases/docs/types/test.ts | 44 +++++++ .../base/symbols2aliases/examples/index.js | 27 ++++ .../plot/base/symbols2aliases/lib/index.js | 43 +++++++ .../plot/base/symbols2aliases/lib/main.js | 53 ++++++++ .../plot/base/symbols2aliases/package.json | 65 ++++++++++ .../plot/base/symbols2aliases/test/test.js | 71 +++++++++++ 10 files changed, 551 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/README.md create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/package.json create mode 100644 lib/node_modules/@stdlib/plot/base/symbols2aliases/test/test.js diff --git a/lib/node_modules/@stdlib/plot/base/symbols2aliases/README.md b/lib/node_modules/@stdlib/plot/base/symbols2aliases/README.md new file mode 100644 index 000000000000..1ca52ed9b95b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/README.md @@ -0,0 +1,119 @@ + + +# symbols2aliases + +> Convert an array of symbol [aliases][@stdlib/plot/base/symbol-aliases] and/or [shorthands][@stdlib/plot/base/symbol-shorthands] to canonical [symbol aliases][@stdlib/plot/base/symbol-aliases]. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var symbols2aliases = require( '@stdlib/plot/base/symbols2aliases' ); +``` + +#### symbols2aliases( symbols ) + +Converts an array of symbol [aliases][@stdlib/plot/base/symbol-aliases] and/or [shorthands][@stdlib/plot/base/symbol-shorthands] to canonical [symbol aliases][@stdlib/plot/base/symbol-aliases]. + +```javascript +var out = symbols2aliases( [ 'o', 's' ] ); +// returns [ 'circle', 'square' ] +``` + +If unable to resolve an alias for an element of the input array, the corresponding element in the output array is `null`. + +```javascript +var out = symbols2aliases( [ 'o', 'beep' ] ); +// returns [ 'circle', null ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var logEach = require( '@stdlib/console/log-each' ); +var symbolAliases = require( '@stdlib/plot/base/symbol-aliases' ); +var symbols2aliases = require( '@stdlib/plot/base/symbols2aliases' ); + +var symbols = symbolAliases(); + +logEach( '%s => %s', symbols, symbols2aliases( symbols ) ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/base/symbols2aliases/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/base/symbols2aliases/benchmark/benchmark.js new file mode 100644 index 000000000000..a8c3f38e056c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/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 symbols2aliases = 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 = symbols2aliases( 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/symbols2aliases/docs/repl.txt b/lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/repl.txt new file mode 100644 index 000000000000..035317e4b60e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/repl.txt @@ -0,0 +1,28 @@ + +{{alias}}( symbols ) + Converts an array of symbol aliases and/or shorthands to canonical symbol + aliases. + + If unable to resolve an alias 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 + Canonical symbol aliases. + + Examples + -------- + > var v = {{alias}}( [ 'o', 's' ] ) + [ 'circle', 'square' ] + > v = {{alias}}( [ 'o', 'beep' ] ) + [ 'circle', null ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/types/index.d.ts new file mode 100644 index 000000000000..d2dff3ba0a4d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/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 canonical symbol aliases. +* +* ## Notes +* +* - If unable to resolve an alias for an element of the input array, the corresponding element in the output array is `null`. +* +* @param symbols - symbol aliases and/or shorthands +* @returns canonical symbol aliases +* +* @example +* var v = symbols2aliases( [ 'o', 's' ] ); +* // returns [ 'circle', 'square' ] +* +* v = symbols2aliases( [ 'o', 'beep' ] ); +* // returns [ 'circle', null ] +*/ +declare function symbols2aliases( symbols: Collection ): Array; + + +// EXPORTS // + +export = symbols2aliases; diff --git a/lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/types/test.ts b/lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/types/test.ts new file mode 100644 index 000000000000..b0820d2cfe27 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/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 symbols2aliases = require( './index' ); + + +// TESTS // + +// The function returns an array... +{ + symbols2aliases( [ 'o', '+' ] ); // $ExpectType (string | null)[] +} + +// The compiler throws an error if the function is not provided a collection of strings... +{ + symbols2aliases( 1 ); // $ExpectError + symbols2aliases( true ); // $ExpectError + symbols2aliases( false ); // $ExpectError + symbols2aliases( null ); // $ExpectError + symbols2aliases( undefined ); // $ExpectError + symbols2aliases( {} ); // $ExpectError + symbols2aliases( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + symbols2aliases(); // $ExpectError + symbols2aliases( [ 'o' ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/base/symbols2aliases/examples/index.js b/lib/node_modules/@stdlib/plot/base/symbols2aliases/examples/index.js new file mode 100644 index 000000000000..04ee9b14a993 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/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 symbols2aliases = require( './../lib' ); + +var symbols = symbolAliases(); + +logEach( '%s => %s', symbols, symbols2aliases( symbols ) ); diff --git a/lib/node_modules/@stdlib/plot/base/symbols2aliases/lib/index.js b/lib/node_modules/@stdlib/plot/base/symbols2aliases/lib/index.js new file mode 100644 index 000000000000..6081f921635a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/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 canonical symbol aliases. +* +* @module @stdlib/plot/base/symbols2aliases +* +* @example +* var symbols2aliases = require( '@stdlib/plot/base/symbols2aliases' ); +* +* var v = symbols2aliases( [ 'o', 's' ] ); +* // returns [ 'circle', 'square' ] +* +* v = symbols2aliases( [ 'o', 'beep' ] ); +* // returns [ 'circle', null ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/base/symbols2aliases/lib/main.js b/lib/node_modules/@stdlib/plot/base/symbols2aliases/lib/main.js new file mode 100644 index 000000000000..5bf06e36a2b4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/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 symbol2alias = require( '@stdlib/plot/base/symbol2alias' ); + + +// MAIN // + +/** +* Converts an array of symbol aliases and/or shorthands to canonical symbol aliases. +* +* ## Notes +* +* - If unable to resolve an alias 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} canonical symbol aliases +* +* @example +* var v = symbols2aliases( [ 'o', 's' ] ); +* // returns [ 'circle', 'square' ] +* +* v = symbols2aliases( [ 'o', 'beep' ] ); +* // returns [ 'circle', null ] +*/ +function symbols2aliases( symbols ) { + return map( symbols, symbol2alias ); +} + + +// EXPORTS // + +module.exports = symbols2aliases; diff --git a/lib/node_modules/@stdlib/plot/base/symbols2aliases/package.json b/lib/node_modules/@stdlib/plot/base/symbols2aliases/package.json new file mode 100644 index 000000000000..0ad6fb1eae21 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/plot/base/symbols2aliases", + "version": "0.0.0", + "description": "Convert an array of symbol aliases and/or shorthands to canonical symbol aliases.", + "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", + "alias", + "aliases", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/base/symbols2aliases/test/test.js b/lib/node_modules/@stdlib/plot/base/symbols2aliases/test/test.js new file mode 100644 index 000000000000..e3ef2f7b26f5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/symbols2aliases/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 symbol2alias = require( '@stdlib/plot/base/symbol2alias' ); +var symbols2aliases = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof symbols2aliases, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function converts an array of symbols to aliases', 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( symbol2alias( values[ i ] ) ); + } + actual = symbols2aliases( 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( symbols2aliases( [] ), [], 'returns expected value' ); + t.end(); +}); + +tape( 'if unable to resolve an alias 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, 'circle', null ]; + actual = symbols2aliases( [ 'beep', 'o', 'boop' ] ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +});