Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/signal/names/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<!--

@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.

-->

# signals

> List of reserved Vega signal names.

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## 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' ]
```

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```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
```

</section>

<!-- /.examples -->

<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

</section>

<!-- /.links -->
105 changes: 105 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/signal/names/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -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();
});
29 changes: 29 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/signal/names/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -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<string>
List of signal names.

Examples
--------
> var out = {{alias}}()
e.g., [ 'datum', 'event', ... ]
> out = {{alias}}( 'reserved' )
[ 'datum', 'event', ... ]

See Also
--------

Original file line number Diff line number Diff line change
@@ -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<string>;


// EXPORTS //

export = signals;
51 changes: 51 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/signal/names/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -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
}
Loading
Loading