diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/README.md b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/README.md new file mode 100644 index 000000000000..6ce5029b6e4e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/README.md @@ -0,0 +1,125 @@ + + +# isCompare + +> Test if an input value is an [compare][@stdlib/plot/vega/mark/compare] instance. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var isCompare = require( '@stdlib/plot/vega/base/assert/is-compare' ); +``` + +#### isCompare( value ) + +Tests if an input value is an [compare][@stdlib/plot/vega/mark/compare] instance. + +```javascript +var Compare = require( '@stdlib/plot/vega/mark/compare' ); + +var v = new Compare({ + 'field': 'amount' +}); +var bool = isCompare( v ); +// returns true + +bool = isCompare( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var Compare = require( '@stdlib/plot/vega/mark/compare' ); +var isCompare = require( '@stdlib/plot/vega/base/assert/is-compare' ); + +var v = new Compare({ + 'field': 'amount' +}); +var bool = isCompare( v ); +// returns true + +bool = isCompare( {} ); +// returns false + +bool = isCompare( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/benchmark/benchmark.js new file mode 100644 index 000000000000..10fbd4dccae7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/benchmark/benchmark.js @@ -0,0 +1,94 @@ +/** +* @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 Compare = require( '@stdlib/plot/vega/mark/compare' ); +var pkg = require( './../package.json' ).name; +var isCompare = require( './../lib' ); + + +// MAIN // + +bench( pkg+'::true', function benchmark( b ) { + var values; + var out; + var v; + var i; + + values = [ + new Compare({ + 'field': 'amount' + }), + new Compare({ + 'field': 'amount', + 'order': 'descending' + }) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = values[ i%values.length ]; + out = isCompare( 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(); +}); + +bench( pkg+'::false', function benchmark( b ) { + var values; + var out; + var v; + var i; + + values = [ + 'foo', + 'bar', + '', + 'beep', + 'boop', + [], + {} + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = values[ i%values.length ]; + out = isCompare( 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-compare/docs/repl.txt b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/docs/repl.txt new file mode 100644 index 000000000000..f434dffc0bd6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/docs/repl.txt @@ -0,0 +1,26 @@ + +{{alias}}( value ) + Tests if an input value is an compare instance. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if an input value is an compare instance. + + Examples + -------- + > var Compare = {{alias:@stdlib/plot/vega/mark/compare}}; + > var v = new Compare({ 'field': 'amount' }); + > var bool = {{alias}}( v ) + true + > bool = {{alias}}( {} ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/docs/types/index.d.ts new file mode 100644 index 000000000000..12fc03c20bcd --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/docs/types/index.d.ts @@ -0,0 +1,47 @@ +/* +* @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 an compare instance. +* +* @param v - value to test +* @returns boolean indicating whether an input value is an compare instance +* +* @example +* var Compare = require( '@stdlib/plot/vega/mark/compare' ); +* +* var v = new Compare({ +* 'field': 'amount' +* }); +* var bool = isCompare( v ); +* // returns true +* +* bool = isCompare( {} ); +* // returns false +* +* bool = isCompare( 'foo' ); +* // returns false +*/ +declare function isCompare( v: any ): boolean; + + +// EXPORTS // + +export = isCompare; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/docs/types/test.ts b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/docs/types/test.ts new file mode 100644 index 000000000000..a5d3043de906 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/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 isCompare = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isCompare( {} ); // $ExpectType boolean + isCompare( 'foo' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isCompare(); // $ExpectError + isCompare( undefined, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/examples/index.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/examples/index.js new file mode 100644 index 000000000000..29ce03a90b52 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Compare = require( '@stdlib/plot/vega/mark/compare' ); +var isCompare = require( './../lib' ); + +var v = new Compare({ + 'field': 'amount' +}); +var bool = isCompare( v ); +console.log( bool ); +// => true + +bool = isCompare( {} ); +console.log( bool ); +// => false + +bool = isCompare( 'foo' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/lib/index.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/lib/index.js new file mode 100644 index 000000000000..a904c77bb117 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/lib/index.js @@ -0,0 +1,50 @@ +/** +* @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 an compare instance. +* +* @module @stdlib/plot/vega/base/assert/is-compare +* +* @example +* var Compare = require( '@stdlib/plot/vega/mark/compare' ); +* var isCompare = require( '@stdlib/plot/vega/base/assert/is-compare' ); +* +* var v = new Compare({ +* 'field': 'amount' +* }); +* var bool = isCompare( v ); +* // returns true +* +* bool = isCompare( {} ); +* // returns false +* +* bool = isCompare( '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-compare/lib/main.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/lib/main.js new file mode 100644 index 000000000000..027721793393 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/lib/main.js @@ -0,0 +1,69 @@ +/** +* @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 isObject = require( '@stdlib/assert/is-object' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var Compare = require( '@stdlib/plot/vega/mark/compare' ); + + +// MAIN // + +/** +* Tests whether an input value is an compare instance. +* +* @param {*} value - value to test +* @returns {boolean} boolean indicating whether an input value is an compare instance +* +* @example +* var Compare = require( '@stdlib/plot/vega/mark/compare' ); +* +* var v = new Compare({ +* 'field': 'amount' +* }); +* var bool = isCompare( v ); +* // returns true +* +* bool = isCompare( {} ); +* // returns false +* +* bool = isCompare( 'foo' ); +* // returns false +*/ +function isCompare( value ) { + return ( + value instanceof Compare || + + // The following is a set of rather imperfect heuristics for handling instances originating in a different realm... + ( + isObject( value ) && + isString( value.type ) && + isBoolean( value.resize ) && + isString( value.contains ) + ) + ); +} + + +// EXPORTS // + +module.exports = isCompare; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/package.json b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/package.json new file mode 100644 index 000000000000..714edb837e8c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/plot/vega/base/assert/is-compare", + "version": "0.0.0", + "description": "Test if an input value is an compare instance.", + "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-compare/test/test.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/test/test.js new file mode 100644 index 000000000000..efac6333edc5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-compare/test/test.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 tape = require( 'tape' ); +var Compare = require( '@stdlib/plot/vega/mark/compare' ); +var isCompare = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isCompare, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided an compare instance', function test( t ) { + var values; + var bool; + var i; + + values = [ + new Compare({ + 'field': 'amount' + }), + new Compare({ + 'field': 'amount', + 'order': 'descending' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isCompare( values[ i ] ); + t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns `false` if not provided an compare instance', 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 = isCompare( values[ i ] ); + t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +});