diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/README.md b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/README.md new file mode 100644 index 000000000000..4e1054eebf6b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/README.md @@ -0,0 +1,120 @@ + + +# isSignalName + +> Test if an input value is a valid Vega signal name. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var isSignalName = require( '@stdlib/plot/vega/base/assert/is-signal-name' ); +``` + +#### isSignalName( value ) + +Tests if an input value is a valid Vega signal name. + +```javascript +var bool = isSignalName( 'width' ); +// returns true + +bool = isSignalName( 'datum' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var isSignalName = require( '@stdlib/plot/vega/base/assert/is-signal-name' ); + +var bool = isSignalName( 'width' ); +// returns true + +bool = isSignalName( 'height' ); +// returns true + +bool = isSignalName( 'foo' ); +// returns true + +bool = isSignalName( 'datum' ); +// returns false + +bool = isSignalName( '' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/benchmark/benchmark.js new file mode 100644 index 000000000000..429cc5f60ebb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/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 isSignalName = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var v; + var i; + + values = [ + 'width', + 'height', + 'foo', + 'datum', + 'event', + '', + '123abc', + 'item' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = values[ i%values.length ]; + out = isSignalName( 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/vega/base/assert/is-signal-name/docs/repl.txt b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/docs/repl.txt new file mode 100644 index 000000000000..bfb1910821ae --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/docs/repl.txt @@ -0,0 +1,30 @@ + +{{alias}}( value ) + Tests if an input value is a valid signal name. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if an input value is a valid signal name. + + Examples + -------- + > var bool = {{alias}}( 'width' ) + true + > bool = {{alias}}( 'height' ) + true + > bool = {{alias}}( 'foo' ) + true + > bool = {{alias}}( 'datum' ) + false + > bool = {{alias}}( '' ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/docs/types/index.d.ts new file mode 100644 index 000000000000..197a7261fc8a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/docs/types/index.d.ts @@ -0,0 +1,45 @@ +/* +* @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 valid signal name. +* +* @param v - value to test +* @returns boolean indicating whether an input value is a valid signal name +* +* @example +* var bool = isSignalName( 'width' ); +* // returns true +* +* bool = isSignalName( 'height' ); +* // returns true +* +* bool = isSignalName( 'foo' ); +* // returns true +* +* bool = isSignalName( 'datum' ); +* // returns false +*/ +declare function isSignalName( v: any ): boolean; + + +// EXPORTS // + +export = isSignalName; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/docs/types/test.ts b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/docs/types/test.ts new file mode 100644 index 000000000000..cbcc84858f90 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/docs/types/test.ts @@ -0,0 +1,35 @@ +/* +* @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 isSignalName = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isSignalName( 'width' ); // $ExpectType boolean + isSignalName( 'datum' ); // $ExpectType boolean + isSignalName( 'foo' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isSignalName(); // $ExpectError + isSignalName( undefined, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/examples/index.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/examples/index.js new file mode 100644 index 000000000000..4a1bf82d985e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/examples/index.js @@ -0,0 +1,41 @@ +/** +* @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 isSignalName = require( './../lib' ); + +var bool = isSignalName( 'width' ); +console.log( bool ); +// => true + +bool = isSignalName( 'height' ); +console.log( bool ); +// => true + +bool = isSignalName( 'foo' ); +console.log( bool ); +// => true + +bool = isSignalName( 'datum' ); +console.log( bool ); +// => false + +bool = isSignalName( '' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/lib/index.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/lib/index.js new file mode 100644 index 000000000000..23d6e3c5000f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/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 valid Vega signal name. +* +* @module @stdlib/plot/vega/base/assert/is-signal-name +* +* @example +* var isSignalName = require( '@stdlib/plot/vega/base/assert/is-signal-name' ); +* +* var bool = isSignalName( 'width' ); +* // returns true +* +* bool = isSignalName( 'height' ); +* // returns true +* +* bool = isSignalName( 'foo' ); +* // returns true +* +* bool = isSignalName( 'datum' ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/lib/main.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/lib/main.js new file mode 100644 index 000000000000..6ead630e0f80 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/lib/main.js @@ -0,0 +1,83 @@ +/** +* @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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var contains = require( '@stdlib/array/base/assert/contains' ).factory; + + +// VARIABLES // + +/** +* Regular expression to test whether a string is a valid JavaScript identifier. +* +* @private +* @constant +* @type {RegExp} +*/ +var RE_IDENTIFIER = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/; + +/** +* List of reserved Vega signal names. +* +* @private +* @constant +* @type {Function} +*/ +var isReserved = contains( [ 'datum', 'event', 'item', 'parent' ] ); + + +// MAIN // + +/** +* Tests whether an input value is a valid Vega signal name. +* +* @param {*} v - value to test +* @returns {boolean} boolean indicating whether an input value is a valid Vega signal name +* +* @example +* var bool = isSignalName( 'width' ); +* // returns true +* +* bool = isSignalName( 'height' ); +* // returns true +* +* bool = isSignalName( 'foo' ); +* // returns true +* +* bool = isSignalName( 'datum' ); +* // returns false +* +* bool = isSignalName( '' ); +* // returns false +*/ +function isSignalName( v ) { + return ( + isString( v ) && + RE_IDENTIFIER.test( v ) && + !isReserved( v ) + ); +} + + +// EXPORTS // + +module.exports = isSignalName; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/package.json b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/package.json new file mode 100644 index 000000000000..f834b653279e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/plot/vega/base/assert/is-signal-name", + "version": "0.0.0", + "description": "Test if an input value is a valid Vega signal name.", + "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", + "vega", + "utilities", + "utility", + "utils", + "util", + "assert", + "test", + "check", + "is", + "valid", + "validate", + "validation", + "isvalid" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/test/test.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/test/test.js new file mode 100644 index 000000000000..b76e03b96a82 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-signal-name/test/test.js @@ -0,0 +1,96 @@ +/** +* @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 isSignalName = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isSignalName, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a valid Vega signal name', function test( t ) { + var values; + var bool; + var i; + + values = [ + 'width', + 'height', + 'foo', + '_private', + '$var' + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isSignalName( values[ i ] ); + t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns `false` if provided a reserved Vega keyword', function test( t ) { + var values; + var bool; + var i; + + values = [ + 'datum', + 'event', + 'item', + 'parent' + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isSignalName( values[ i ] ); + t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns `false` if not provided a valid Vega signal name', function test( t ) { + var values; + var bool; + var i; + + values = [ + '', + '123abc', + 'foo bar', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isSignalName( values[ i ] ); + t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +});