From 91c8849e8c9a1fd4d931838ce2551897b78cb1cb Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Mon, 9 Mar 2026 02:25:02 +0530 Subject: [PATCH] feat: add plot/vega/signal/names --- .../@stdlib/plot/vega/signal/names/README.md | 133 ++++++++++++++++++ .../vega/signal/names/benchmark/benchmark.js | 105 ++++++++++++++ .../plot/vega/signal/names/docs/repl.txt | 29 ++++ .../vega/signal/names/docs/types/index.d.ts | 45 ++++++ .../plot/vega/signal/names/docs/types/test.ts | 51 +++++++ .../plot/vega/signal/names/examples/index.js | 40 ++++++ .../plot/vega/signal/names/lib/data.json | 32 +++++ .../plot/vega/signal/names/lib/index.js | 40 ++++++ .../plot/vega/signal/names/lib/main.js | 54 +++++++ .../plot/vega/signal/names/package.json | 62 ++++++++ .../plot/vega/signal/names/test/test.js | 127 +++++++++++++++++ 11 files changed, 718 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/README.md create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/lib/data.json create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/package.json create mode 100644 lib/node_modules/@stdlib/plot/vega/signal/names/test/test.js diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/README.md b/lib/node_modules/@stdlib/plot/vega/signal/names/README.md new file mode 100644 index 000000000000..798e8abe7482 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/README.md @@ -0,0 +1,133 @@ + + +# signals + +> List of reserved Vega signal names. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var signals = require( '@stdlib/plot/vega/signal/names' ); +``` + +#### signals( \[kind] ) + +Returns a list of reserved signal names. + +```javascript +var out = signals(); +// e.g., returns [ 'datum', 'event', ... ] +``` + +The function has the following parameters: + +- **kind**: signal kind. Must be one of the following: + + - `'all'`: all signal names (default). + - `'reserved'`: reserved signal names. + - `'built_in'`: built-in signal names. + - `'special'`: special signal names. + +By default, the function returns all signal names. To return only those signals of a specified kind, provide a `kind` argument. + +```javascript +var out = signals( 'reserved' ); +// e.g., returns [ 'datum', 'event', 'item', 'parent' ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var signals = require( '@stdlib/plot/vega/signal/names' ); + +var isSignal = contains( signals() ); + +var bool = isSignal( 'datum' ); +// returns true + +bool = isSignal( 'width' ); +// returns true + +bool = isSignal( 'beep' ); +// returns false + +bool = isSignal( 'boop' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/signal/names/benchmark/benchmark.js new file mode 100644 index 000000000000..ac67efc67a93 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var pkg = require( './../package.json' ).name; +var signals = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = signals(); + if ( out.length < 2 ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isStringArray( out ) ) { + b.fail( 'should return an array of strings' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':kind=reserved', function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = signals( 'reserved' ); + if ( out.length < 2 ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isStringArray( out ) ) { + b.fail( 'should return an array of strings' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':kind=built_in', function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = signals( 'built_in' ); + if ( out.length < 2 ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isStringArray( out ) ) { + b.fail( 'should return an array of strings' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':kind=special', function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = signals( 'special' ); + if ( out.length < 1 ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isStringArray( out ) ) { + b.fail( 'should return an array of strings' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/docs/repl.txt b/lib/node_modules/@stdlib/plot/vega/signal/names/docs/repl.txt new file mode 100644 index 000000000000..f19cc5bec98d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/docs/repl.txt @@ -0,0 +1,29 @@ + +{{alias}}( [kind] ) + Returns a list of reserved signal names. + + Parameters + ---------- + kind: string (optional) + Signal kind. Must be one of the following: + + - all: all signal names (default). + - reserved: reserved signal names. + - built_in: built-in signal names. + - special: special signal names. + + Returns + ------- + out: Array + List of signal names. + + Examples + -------- + > var out = {{alias}}() + e.g., [ 'datum', 'event', ... ] + > out = {{alias}}( 'reserved' ) + [ 'datum', 'event', ... ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/vega/signal/names/docs/types/index.d.ts new file mode 100644 index 000000000000..f566b2a6b1fc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/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 + +/** +* Signal kind. +*/ +type SignalKind = 'all' | 'reserved' | 'built_in' | 'special'; + +/** +* Returns a list of reserved signal names. +* +* @param kind - signal kind +* @returns list of signal names +* +* @example +* var out = signals(); +* // e.g., returns [ 'datum', 'event', ... ] +* +* @example +* var list = signals( 'reserved' ); +* // e.g., returns [ 'datum', 'event', ... ] +*/ +declare function signals( kind?: SignalKind ): Array; + + +// EXPORTS // + +export = signals; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/docs/types/test.ts b/lib/node_modules/@stdlib/plot/vega/signal/names/docs/types/test.ts new file mode 100644 index 000000000000..9d245f3a021d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/docs/types/test.ts @@ -0,0 +1,51 @@ +/* +* @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 signals = require( './index' ); + + +// TESTS // + +// The function returns an array of strings when not provided any arguments... +{ + signals(); // $ExpectType string[] +} + +// The function returns an array of strings when provided a recognized signal kind... +{ + signals( 'all' ); // $ExpectType string[] + signals( 'reserved' ); // $ExpectType string[] + signals( 'built_in' ); // $ExpectType string[] + signals( 'special' ); // $ExpectType string[] +} + +// The compiler throws an error if the function is provided an invalid first argument... +{ + signals( 5 ); // $ExpectError + signals( true ); // $ExpectError + signals( false ); // $ExpectError + signals( null ); // $ExpectError + signals( [] ); // $ExpectError + signals( {} ); // $ExpectError + signals( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + signals( 'reserved', {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/examples/index.js b/lib/node_modules/@stdlib/plot/vega/signal/names/examples/index.js new file mode 100644 index 000000000000..832b3f7e7a09 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/examples/index.js @@ -0,0 +1,40 @@ +/** +* @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 contains = require( '@stdlib/array/base/assert/contains' ).factory; +var signals = require( './../lib' ); + +var isSignal = contains( signals() ); + +var bool = isSignal( 'datum' ); +console.log( bool ); +// => true + +bool = isSignal( 'width' ); +console.log( bool ); +// => true + +bool = isSignal( 'beep' ); +console.log( bool ); +// => false + +bool = isSignal( 'boop' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/lib/data.json b/lib/node_modules/@stdlib/plot/vega/signal/names/lib/data.json new file mode 100644 index 000000000000..ef70af47261e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/lib/data.json @@ -0,0 +1,32 @@ +{ + "all": [ + "datum", + "event", + "item", + "parent", + + "width", + "height", + "padding", + "autosize", + "background", + + "cursor" + ], + "reserved": [ + "datum", + "event", + "item", + "parent" + ], + "built_in": [ + "width", + "height", + "padding", + "autosize", + "background" + ], + "special": [ + "cursor" + ] +} diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/lib/index.js b/lib/node_modules/@stdlib/plot/vega/signal/names/lib/index.js new file mode 100644 index 000000000000..9bcdf3ed5891 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/lib/index.js @@ -0,0 +1,40 @@ +/** +* @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'; + +/** +* Return a list of reserved signal names. +* +* @module @stdlib/plot/vega/signal/names +* +* @example +* var signals = require( '@stdlib/plot/vega/signal/names' ); +* +* var out = signals(); +* // e.g., returns [ 'datum', 'event', ... ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/lib/main.js b/lib/node_modules/@stdlib/plot/vega/signal/names/lib/main.js new file mode 100644 index 000000000000..c957c54243b5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/lib/main.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 DATA = require( './data.json' ); + + +// MAIN // + +/** +* Returns a list of reserved signal names. +* +* @param {string} [kind] - signal kind +* @returns {StringArray} list of reserved signal names +* +* @example +* var out = signals(); +* // e.g., returns [ 'datum', 'event', ... ] +* +* @example +* var list = signals( 'reserved' ); +* // e.g., returns [ 'datum', 'event', ... ] +*/ +function signals( kind ) { + var v; + if ( arguments.length ) { + v = DATA[ kind ]; + return ( v ) ? v.slice() : []; + } + return DATA.all.slice(); +} + + +// EXPORTS // + +module.exports = signals; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/package.json b/lib/node_modules/@stdlib/plot/vega/signal/names/package.json new file mode 100644 index 000000000000..e0068f11b556 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/package.json @@ -0,0 +1,62 @@ +{ + "name": "@stdlib/plot/vega/signal/names", + "version": "0.0.0", + "description": "List of reserved Vega signal names.", + "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", + "vega", + "signals", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/vega/signal/names/test/test.js b/lib/node_modules/@stdlib/plot/vega/signal/names/test/test.js new file mode 100644 index 000000000000..c5ecc3ea5e30 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/names/test/test.js @@ -0,0 +1,127 @@ +/** +* @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 signals = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof signals, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a list of signal names (default)', function test( t ) { + var expected; + var actual; + + expected = [ + 'datum', + 'event', + 'item', + 'parent', + + 'width', + 'height', + 'padding', + 'autosize', + 'background', + + 'cursor' + ]; + actual = signals(); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a list of signal names (kind=all)', function test( t ) { + var expected; + var actual; + + expected = [ + 'datum', + 'event', + 'item', + 'parent', + + 'width', + 'height', + 'padding', + 'autosize', + 'background', + + 'cursor' + ]; + actual = signals( 'all' ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a list of reserved signal names (kind=reserved)', function test( t ) { + var expected; + var actual; + + expected = [ + 'datum', + 'event', + 'item', + 'parent' + ]; + actual = signals( 'reserved' ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a list of signal names (kind=built_in)', function test( t ) { + var expected; + var actual; + + expected = [ + 'width', + 'height', + 'padding', + 'autosize', + 'background' + ]; + actual = signals( 'built_in' ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a list of signal names (kind=special)', function test( t ) { + var expected; + var actual; + + expected = [ + 'cursor' + ]; + actual = signals( 'special' ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +});