diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/README.md b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/README.md new file mode 100644 index 000000000000..5cadd58a71f6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/README.md @@ -0,0 +1,119 @@ + + +# isLegendDirection + +> Test if an input value is a supported [legend direction][@stdlib/plot/vega/legend/directions]. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var isLegendDirection = require( '@stdlib/plot/vega/base/assert/is-legend-direction' ); +``` + +#### isLegendDirection( value ) + +Tests if an input value is a supported [legend direction][@stdlib/plot/vega/legend/directions]. + +```javascript +var bool = isLegendDirection( 'horizontal' ); +// returns true + +bool = isLegendDirection( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var isLegendDirection = require( '@stdlib/plot/vega/base/assert/is-legend-direction' ); + +var bool = isLegendDirection( 'horizontal' ); +// returns true + +bool = isLegendDirection( 'vertical' ); +// returns true + +bool = isLegendDirection( '' ); +// returns false + +bool = isLegendDirection( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/benchmark/benchmark.js new file mode 100644 index 000000000000..9fb448a016ad --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/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 isLegendDirection = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var v; + var i; + + values = [ + 'horizontal', + 'vertical', + + 'foo', + 'bar', + '', + 'beep', + 'boop' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = values[ i%values.length ]; + out = isLegendDirection( 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-legend-direction/docs/repl.txt b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/docs/repl.txt new file mode 100644 index 000000000000..521e5e79cc0d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/docs/repl.txt @@ -0,0 +1,29 @@ + +{{alias}}( value ) + Tests if an input value is a supported legend direction. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if an input value is a supported legend + direction. + + Examples + -------- + > var bool = {{alias}}( 'horizontal' ) + true + > bool = {{alias}}( 'vertical' ) + true + > bool = {{alias}}( '' ) + false + > bool = {{alias}}( 'beep' ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/docs/types/index.d.ts new file mode 100644 index 000000000000..8d169402d54b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/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 supported legend direction. +* +* @param v - value to test +* @returns boolean indicating whether an input value is a supported legend direction +* +* @example +* var bool = isLegendDirection( 'horizontal' ); +* // returns true +* +* bool = isLegendDirection( 'vertical' ); +* // returns true +* +* bool = isLegendDirection( 'bar' ); +* // returns false +* +* bool = isLegendDirection( 'foo' ); +* // returns false +*/ +declare function isLegendDirection( v: any ): boolean; + + +// EXPORTS // + +export = isLegendDirection; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/docs/types/test.ts b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/docs/types/test.ts new file mode 100644 index 000000000000..08a08f4d6331 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/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 isLegendDirection = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isLegendDirection( 'horizontal' ); // $ExpectType boolean + isLegendDirection( 'foo' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isLegendDirection(); // $ExpectError + isLegendDirection( undefined, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/examples/index.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/examples/index.js new file mode 100644 index 000000000000..d312b7d96540 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/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 isLegendDirection = require( './../lib' ); + +var bool = isLegendDirection( 'horizontal' ); +console.log( bool ); +// => true + +bool = isLegendDirection( 'vertical' ); +console.log( bool ); +// => true + +bool = isLegendDirection( '' ); +console.log( bool ); +// => false + +bool = isLegendDirection( 'foo' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/lib/index.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/lib/index.js new file mode 100644 index 000000000000..58672a81ad4d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/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 legend direction. +* +* @module @stdlib/plot/vega/base/assert/is-legend-direction +* +* @example +* var isLegendDirection = require( '@stdlib/plot/vega/base/assert/is-legend-direction' ); +* +* var bool = isLegendDirection( 'horizontal' ); +* // returns true +* +* bool = isLegendDirection( 'vertical' ); +* // returns true +* +* bool = isLegendDirection( 'bar' ); +* // returns false +* +* bool = isLegendDirection( 'foo' ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/lib/main.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/lib/main.js new file mode 100644 index 000000000000..7e5652f45957 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/lib/main.js @@ -0,0 +1,55 @@ +/** +* @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 contains = require( '@stdlib/array/base/assert/contains' ).factory; +var values = require( '@stdlib/plot/vega/legend/directions' ); + + +// MAIN // + +/** +* Tests whether an input value is a supported legend direction. +* +* @name isLegendDirection +* @type {Function} +* @param {*} v - value to test +* @returns {boolean} boolean indicating whether an input value is a supported legend direction +* +* @example +* var bool = isLegendDirection( 'horizontal' ); +* // returns true +* +* bool = isLegendDirection( 'vertical' ); +* // returns true +* +* bool = isLegendDirection( 'bar' ); +* // returns false +* +* bool = isLegendDirection( 'foo' ); +* // returns false +*/ +var isLegendDirection = contains( values() ); + + +// EXPORTS // + +module.exports = isLegendDirection; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/package.json b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/package.json new file mode 100644 index 000000000000..e367e5e4f1f4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/plot/vega/base/assert/is-legend-direction", + "version": "0.0.0", + "description": "Test if an input value is a supported legend direction.", + "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-legend-direction/test/test.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/test/test.js new file mode 100644 index 000000000000..af8ef78042ac --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-legend-direction/test/test.js @@ -0,0 +1,77 @@ +/** +* @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 isLegendDirection = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isLegendDirection, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a supported legend direction', function test( t ) { + var values; + var bool; + var i; + + values = [ + 'horizontal', + 'vertical' + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isLegendDirection( 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 legend direction', 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 = isLegendDirection( values[ i ] ); + t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +});