From d385090051cc2ad8fc9417473232e79f4d17493b Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Thu, 30 Jul 2026 22:04:11 +0530 Subject: [PATCH] feat: add plot/vega/base/assert/is-area-mark-encoding --- .../assert/is-area-mark-encoding/README.md | 139 ++++++++++++++++++ .../benchmark/benchmark.js | 106 +++++++++++++ .../is-area-mark-encoding/docs/repl.txt | 30 ++++ .../docs/types/index.d.ts | 54 +++++++ .../is-area-mark-encoding/docs/types/test.ts | 34 +++++ .../is-area-mark-encoding/examples/index.js | 44 ++++++ .../assert/is-area-mark-encoding/lib/index.js | 57 +++++++ .../assert/is-area-mark-encoding/lib/main.js | 72 +++++++++ .../assert/is-area-mark-encoding/package.json | 70 +++++++++ .../assert/is-area-mark-encoding/test/test.js | 86 +++++++++++ 10 files changed, 692 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/README.md create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/package.json create mode 100644 lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/test/test.js diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/README.md b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/README.md new file mode 100644 index 000000000000..fbeeb4a38efe --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/README.md @@ -0,0 +1,139 @@ + + +# isAreaMarkEncoding + +> Test if an input value is an area mark [encoding][@stdlib/plot/vega/mark/area/encoding]. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var isAreaMarkEncoding = require( '@stdlib/plot/vega/base/assert/is-area-mark-encoding' ); +``` + +#### isAreaMarkEncoding( value ) + +Tests if an input value is an area mark [encoding][@stdlib/plot/vega/mark/area/encoding]. + +```javascript +var Value = require( '@stdlib/plot/vega/value/ctor' ); +var EncodingSet = require( '@stdlib/plot/vega/mark/area/encoding-set' ); +var Encoding = require( '@stdlib/plot/vega/mark/area/encoding' ); + +var v = new Encoding({ + 'enter': new EncodingSet({ + 'x': new Value({ + 'field': 'x', + 'scale': 'xScale' + }) + }) +}); +var bool = isAreaMarkEncoding( v ); +// returns true + +bool = isAreaMarkEncoding( {} ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var Value = require( '@stdlib/plot/vega/value/ctor' ); +var EncodingSet = require( '@stdlib/plot/vega/mark/area/encoding-set' ); +var Encoding = require( '@stdlib/plot/vega/mark/area/encoding' ); +var isAreaMarkEncoding = require( '@stdlib/plot/vega/base/assert/is-area-mark-encoding' ); + +var v = new Encoding({ + 'update': new EncodingSet({ + 'x': new Value({ + 'field': 'x', + 'scale': 'xScale' + }) + }) +}); +var bool = isAreaMarkEncoding( v ); +// returns true + +bool = isAreaMarkEncoding( {} ); +// returns false + +bool = isAreaMarkEncoding( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/benchmark/benchmark.js new file mode 100644 index 000000000000..9dcee135a56f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/benchmark/benchmark.js @@ -0,0 +1,106 @@ +/** +* @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 EncodingSet = require( '@stdlib/plot/vega/mark/area/encoding-set' ); +var Encoding = require( '@stdlib/plot/vega/mark/area/encoding' ); +var Value = require( '@stdlib/plot/vega/value/ctor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var isAreaMarkEncoding = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::true', pkg ), function benchmark( b ) { + var values; + var out; + var v; + var i; + + values = [ + new Encoding({ + 'update': new EncodingSet({ + 'x': new Value({ + 'field': 'x', + 'scale': 'xScale' + }) + }) + }), + new Encoding({ + 'enter': new EncodingSet({ + 'y': new Value({ + 'field': 'y', + 'scale': 'yScale' + }) + }) + }) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = values[ i%values.length ]; + out = isAreaMarkEncoding( 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( format( '%s::false', pkg ), 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 = isAreaMarkEncoding( 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-area-mark-encoding/docs/repl.txt b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/repl.txt new file mode 100644 index 000000000000..c4a946e0a610 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/repl.txt @@ -0,0 +1,30 @@ + +{{alias}}( value ) + Tests if an input value is an area mark encoding. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if an input value is an area mark encoding. + + Examples + -------- + > var o = { 'field': 'x', 'scale': 'xScale' }; + > var v = new {{alias:@stdlib/plot/vega/value/ctor}}( o ); + > o = { 'x': v }; + > v = new {{alias:@stdlib/plot/vega/mark/area/encoding-set}}( o ); + > o = { 'update': v }; + > v = new {{alias:@stdlib/plot/vega/mark/area/encoding}}( o ); + > var bool = {{alias}}( v ) + true + > bool = {{alias}}( {} ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/types/index.d.ts new file mode 100644 index 000000000000..3f3682fe5fa0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/types/index.d.ts @@ -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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests whether an input value is an area mark encoding. +* +* @param v - value to test +* @returns boolean indicating whether an input value is an area mark encoding +* +* @example +* var Value = require( '@stdlib/plot/vega/value/ctor' ); +* var EncodingSet = require( '@stdlib/plot/vega/mark/area/encoding-set' ); +* var Encoding = require( '@stdlib/plot/vega/mark/area/encoding' ); +* +* var v = new Encoding({ +* 'update': new EncodingSet({ +* 'x': new Value({ +* 'field': 'x', +* 'scale': 'xScale' +* }) +* }) +* }); +* var bool = isAreaMarkEncoding( v ); +* // returns true +* +* bool = isAreaMarkEncoding( {} ); +* // returns false +* +* bool = isAreaMarkEncoding( 'foo' ); +* // returns false +*/ +declare function isAreaMarkEncoding( v: any ): boolean; + + +// EXPORTS // + +export = isAreaMarkEncoding; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/types/test.ts b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/docs/types/test.ts new file mode 100644 index 000000000000..7f0d87b0b90b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/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 isAreaMarkEncoding = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isAreaMarkEncoding( {} ); // $ExpectType boolean + isAreaMarkEncoding( 'foo' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isAreaMarkEncoding(); // $ExpectError + isAreaMarkEncoding( undefined, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/examples/index.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/examples/index.js new file mode 100644 index 000000000000..9a3c96e2c646 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/examples/index.js @@ -0,0 +1,44 @@ +/** +* @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 Value = require( '@stdlib/plot/vega/value/ctor' ); +var EncodingSet = require( '@stdlib/plot/vega/mark/area/encoding-set' ); +var Encoding = require( '@stdlib/plot/vega/mark/area/encoding' ); +var isAreaMarkEncoding = require( './../lib' ); + +var v = new Encoding({ + 'update': new EncodingSet({ + 'x': new Value({ + 'field': 'x', + 'scale': 'xScale' + }) + }) +}); +var bool = isAreaMarkEncoding( v ); +console.log( bool ); +// => true + +bool = isAreaMarkEncoding( {} ); +console.log( bool ); +// => false + +bool = isAreaMarkEncoding( 'foo' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/lib/index.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/lib/index.js new file mode 100644 index 000000000000..13b9c0589705 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/lib/index.js @@ -0,0 +1,57 @@ +/** +* @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 area mark encoding. +* +* @module @stdlib/plot/vega/base/assert/is-area-mark-encoding +* +* @example +* var Value = require( '@stdlib/plot/vega/value/ctor' ); +* var EncodingSet = require( '@stdlib/plot/vega/mark/area/encoding-set' ); +* var Encoding = require( '@stdlib/plot/vega/mark/area/encoding' ); +* var isAreaMarkEncoding = require( '@stdlib/plot/vega/base/assert/is-area-mark-encoding' ); +* +* var v = new Encoding({ +* 'update': new EncodingSet({ +* 'x': new Value({ +* 'field': 'x', +* 'scale': 'xScale' +* }) +* }) +* }); +* var bool = isAreaMarkEncoding( v ); +* // returns true +* +* bool = isAreaMarkEncoding( {} ); +* // returns false +* +* bool = isAreaMarkEncoding( '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-area-mark-encoding/lib/main.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/lib/main.js new file mode 100644 index 000000000000..618387692a79 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/lib/main.js @@ -0,0 +1,72 @@ +/** +* @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 Encoding = require( '@stdlib/plot/vega/mark/area/encoding' ); + + +// MAIN // + +/** +* Tests whether an input value is an area mark encoding. +* +* @param {*} value - value to test +* @returns {boolean} boolean indicating whether an input value is an area mark encoding +* +* @example +* var Value = require( '@stdlib/plot/vega/value/ctor' ); +* var EncodingSet = require( '@stdlib/plot/vega/mark/area/encoding-set' ); +* var Encoding = require( '@stdlib/plot/vega/mark/area/encoding' ); +* +* var v = new Encoding({ +* 'update': new EncodingSet({ +* 'x': new Value({ +* 'field': 'x', +* 'scale': 'xScale' +* }) +* }) +* }); +* var bool = isAreaMarkEncoding( v ); +* // returns true +* +* bool = isAreaMarkEncoding( {} ); +* // returns false +* +* bool = isAreaMarkEncoding( 'foo' ); +* // returns false +*/ +function isAreaMarkEncoding( value ) { + return ( + value instanceof Encoding || + + // The following is a set of rather imperfect heuristics for handling instances originating in a different realm... + ( + isObject( value ) && + value.constructor.name === 'AreaEncoding' + ) + ); +} + + +// EXPORTS // + +module.exports = isAreaMarkEncoding; diff --git a/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/package.json b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/package.json new file mode 100644 index 000000000000..236dcedecc59 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/plot/vega/base/assert/is-area-mark-encoding", + "version": "0.0.0", + "description": "Test if an input value is an area mark encoding.", + "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-area-mark-encoding/test/test.js b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/test/test.js new file mode 100644 index 000000000000..2370605b882e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/assert/is-area-mark-encoding/test/test.js @@ -0,0 +1,86 @@ +/** +* @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 Value = require( '@stdlib/plot/vega/value/ctor' ); +var EncodingSet = require( '@stdlib/plot/vega/mark/area/encoding-set' ); +var Encoding = require( '@stdlib/plot/vega/mark/area/encoding' ); +var isAreaMarkEncoding = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isAreaMarkEncoding, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided an area mark encoding instance', function test( t ) { + var values; + var bool; + var i; + + values = [ + new Encoding({ + 'update': new EncodingSet({ + 'x': new Value({ + 'field': 'x', + 'scale': 'xScale' + }) + }) + }) + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isAreaMarkEncoding( values[ i ] ); + t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns `false` if not provided an area mark encoding 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 = isAreaMarkEncoding( values[ i ] ); + t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +});