From 31492d436ce590f93a67e60d13006d58594abbd4 Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Sat, 15 Aug 2026 17:56:46 +0530 Subject: [PATCH] feat: add plot/base/assert/is-symbol --- 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/assert/is-symbol/README.md | 125 ++++++++++++++++++ .../assert/is-symbol/benchmark/benchmark.js | 62 +++++++++ .../plot/base/assert/is-symbol/docs/repl.txt | 28 ++++ .../assert/is-symbol/docs/types/index.d.ts | 42 ++++++ .../base/assert/is-symbol/docs/types/test.ts | 34 +++++ .../base/assert/is-symbol/examples/index.js | 37 ++++++ .../plot/base/assert/is-symbol/lib/index.js | 49 +++++++ .../plot/base/assert/is-symbol/lib/main.js | 59 +++++++++ .../plot/base/assert/is-symbol/package.json | 72 ++++++++++ .../plot/base/assert/is-symbol/test/test.js | 76 +++++++++++ 10 files changed, 584 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/README.md create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/package.json create mode 100644 lib/node_modules/@stdlib/plot/base/assert/is-symbol/test/test.js diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/README.md b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/README.md new file mode 100644 index 000000000000..c2379d68b025 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/README.md @@ -0,0 +1,125 @@ + + +# isSymbol + +> Test if an input value is a supported symbol. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var isSymbol = require( '@stdlib/plot/base/assert/is-symbol' ); +``` + +#### isSymbol( value ) + +Tests if an input value is a supported symbol. + +```javascript +var bool = isSymbol( 'circle' ); +// returns true + +bool = isSymbol( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +## Notes + +- A symbol is either a [symbol alias][@stdlib/plot/base/symbol-aliases] (e.g., `circle`) or a [symbol shorthand][@stdlib/plot/base/symbol-shorthands] (e.g., `o`). + +
+ + + + + +
+ +## Examples + + + +```javascript +var isSymbol = require( '@stdlib/plot/base/assert/is-symbol' ); + +var bool = isSymbol( 'circle' ); +// returns true + +bool = isSymbol( 'o' ); +// returns true + +bool = isSymbol( '' ); +// returns false + +bool = isSymbol( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/benchmark/benchmark.js new file mode 100644 index 000000000000..e2e51630b49d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/benchmark/benchmark.js @@ -0,0 +1,62 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isSymbol = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var v; + var i; + + values = [ + 'circle', + 'o', + + 'foo', + 'bar', + '', + 'beep', + 'boop' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = values[ i%values.length ]; + out = isSymbol( v ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/repl.txt b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/repl.txt new file mode 100644 index 000000000000..d6c51d9e2bc7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/repl.txt @@ -0,0 +1,28 @@ + +{{alias}}( value ) + Tests if an input value is a supported symbol. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if an input value is a supported symbol. + + Examples + -------- + > var bool = {{alias}}( 'circle' ) + true + > bool = {{alias}}( 'o' ) + true + > bool = {{alias}}( '' ) + false + > bool = {{alias}}( 'beep' ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/types/index.d.ts new file mode 100644 index 000000000000..b17fc063f3c3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/types/index.d.ts @@ -0,0 +1,42 @@ +/* +* @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 + +/** +* Tests whether an input value is a supported symbol. +* +* @param v - value to test +* @returns boolean indicating whether an input value is a supported symbol +* +* @example +* var bool = isSymbol( 'circle' ); +* // returns true +* +* bool = isSymbol( 'o' ); +* // returns true +* +* bool = isSymbol( 'foo' ); +* // returns false +*/ +declare function isSymbol( v: any ): boolean; + + +// EXPORTS // + +export = isSymbol; diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/types/test.ts b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/types/test.ts new file mode 100644 index 000000000000..728f2709b543 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/docs/types/test.ts @@ -0,0 +1,34 @@ +/* +* @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 isSymbol = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isSymbol( 'circle' ); // $ExpectType boolean + isSymbol( 'foo' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isSymbol(); // $ExpectError + isSymbol( undefined, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/examples/index.js b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/examples/index.js new file mode 100644 index 000000000000..5bd4cb75c2e2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/examples/index.js @@ -0,0 +1,37 @@ +/** +* @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 isSymbol = require( './../lib' ); + +var bool = isSymbol( 'circle' ); +console.log( bool ); +// => true + +bool = isSymbol( 'o' ); +console.log( bool ); +// => true + +bool = isSymbol( '' ); +console.log( bool ); +// => false + +bool = isSymbol( 'foo' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/lib/index.js b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/lib/index.js new file mode 100644 index 000000000000..7e784d9a9efa --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/lib/index.js @@ -0,0 +1,49 @@ +/** +* @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'; + +/** +* Test whether an input value is a supported symbol. +* +* @module @stdlib/plot/base/assert/is-symbol +* +* @example +* var isSymbol = require( '@stdlib/plot/base/assert/is-symbol' ); +* +* var bool = isSymbol( 'circle' ); +* // returns true +* +* bool = isSymbol( 'o' ); +* // returns true +* +* bool = isSymbol( 'foo' ); +* // returns false +* +* bool = isSymbol( '' ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/lib/main.js b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/lib/main.js new file mode 100644 index 000000000000..f140a4ebc8c9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/lib/main.js @@ -0,0 +1,59 @@ +/** +* @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 isSymbolShorthand = require( '@stdlib/plot/base/assert/is-symbol-shorthand' ); +var isSymbolAlias = require( '@stdlib/plot/base/assert/is-symbol-alias' ); + + +// MAIN // + +/** +* Tests whether an input value is a supported symbol. +* +* ## Notes +* +* - A symbol is either a symbol alias or a symbol shorthand. +* +* @param {*} v - value to test +* @returns {boolean} boolean indicating whether an input value is a supported symbol +* +* @example +* var bool = isSymbol( 'circle' ); +* // returns true +* +* bool = isSymbol( 'o' ); +* // returns true +* +* bool = isSymbol( 'foo' ); +* // returns false +* +* bool = isSymbol( '' ); +* // returns false +*/ +function isSymbol( v ) { + return ( isSymbolAlias( v ) || isSymbolShorthand( v ) ); +} + + +// EXPORTS // + +module.exports = isSymbol; diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/package.json b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/package.json new file mode 100644 index 000000000000..a82991e824a9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/plot/base/assert/is-symbol", + "version": "0.0.0", + "description": "Test if an input value is a supported symbol.", + "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", + "alias", + "shorthand", + "utilities", + "utility", + "utils", + "util", + "assert", + "test", + "check", + "is", + "valid", + "validate", + "validation", + "isvalid" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-symbol/test/test.js b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/test/test.js new file mode 100644 index 000000000000..9b5a36e81446 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-symbol/test/test.js @@ -0,0 +1,76 @@ +/** +* @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 symbolShorthands = require( '@stdlib/plot/base/symbol-shorthands' ); +var symbolAliases = require( '@stdlib/plot/base/symbol-aliases' ); +var isSymbol = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isSymbol, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a supported symbol', function test( t ) { + var values; + var bool; + var i; + + values = symbolAliases().concat( symbolShorthands() ); + for ( i = 0; i < values.length; i++ ) { + bool = isSymbol( values[ i ] ); + t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns `false` if not provided a supported symbol', function test( t ) { + var values; + var bool; + var i; + + values = [ + '', + 'beep', + 'boop', + 'foo', + 'bar', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isSymbol( values[ i ] ); + t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +});