From 111469118501cc90f99818159cadd199547d1ad0 Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Sun, 14 Jun 2026 23:21:17 +0530 Subject: [PATCH] feat: add plot/vega/transform/stack/offsets --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../vega/transform/stack/offsets/README.md | 120 ++++++++++++++++++ .../stack/offsets/benchmark/benchmark.js | 48 +++++++ .../transform/stack/offsets/docs/repl.txt | 17 +++ .../stack/offsets/docs/types/index.d.ts | 35 +++++ .../stack/offsets/docs/types/test.ts | 32 +++++ .../transform/stack/offsets/examples/index.js | 44 +++++++ .../transform/stack/offsets/lib/data.json | 5 + .../vega/transform/stack/offsets/lib/index.js | 40 ++++++ .../vega/transform/stack/offsets/lib/main.js | 44 +++++++ .../vega/transform/stack/offsets/package.json | 65 ++++++++++ .../vega/transform/stack/offsets/test/test.js | 48 +++++++ 11 files changed, 498 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/README.md create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/data.json create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/package.json create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/test/test.js diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/README.md b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/README.md new file mode 100644 index 000000000000..619e1aabf7e8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/README.md @@ -0,0 +1,120 @@ + + +# stackTransformOffsets + +> List of supported Vega stack transform offsets. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var stackTransformOffsets = require( '@stdlib/plot/vega/transform/stack/offsets' ); +``` + +#### stackTransformOffsets() + +Returns a list of stack transform offsets. + +```javascript +var out = stackTransformOffsets(); +// returns [ 'center', 'normalize', 'zero' ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var stackTransformOffsets = require( '@stdlib/plot/vega/transform/stack/offsets' ); + +var isStackTransformOffset = contains( stackTransformOffsets() ); + +var bool = isStackTransformOffset( 'center' ); +// returns true + +bool = isStackTransformOffset( 'normalize' ); +// returns true + +bool = isStackTransformOffset( 'zero' ); +// returns true + +bool = isStackTransformOffset( 'beep' ); +// returns false + +bool = isStackTransformOffset( 'boop' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/benchmark/benchmark.js new file mode 100644 index 000000000000..c050c1ea6687 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/benchmark/benchmark.js @@ -0,0 +1,48 @@ +/** +* @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 stackTransformOffsets = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = stackTransformOffsets(); + if ( out.length < 3 ) { + 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/transform/stack/offsets/docs/repl.txt b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/repl.txt new file mode 100644 index 000000000000..a39e14fafd91 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/repl.txt @@ -0,0 +1,17 @@ + +{{alias}}() + Returns a list of stack transform offsets. + + Returns + ------- + out: Array + List of stack transform offsets. + + Examples + -------- + > var out = {{alias}}() + [ 'center', 'normalize', 'zero' ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/types/index.d.ts new file mode 100644 index 000000000000..794d412b560c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/types/index.d.ts @@ -0,0 +1,35 @@ +/* +* @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 + +/** +* Returns a list of stack transform offsets. +* +* @returns list of stack transform offsets +* +* @example +* var list = stackTransformOffsets(); +* // returns [ 'center', 'normalize', 'zero' ] +*/ +declare function stackTransformOffsets(): Array; + + +// EXPORTS // + +export = stackTransformOffsets; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/types/test.ts b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/types/test.ts new file mode 100644 index 000000000000..8258b5279a88 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/docs/types/test.ts @@ -0,0 +1,32 @@ +/* +* @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 stackTransformOffsets = require( './index' ); + + +// TESTS // + +// The function returns an array of strings... +{ + stackTransformOffsets(); // $ExpectType string[] +} + +// The compiler throws an error if the function is provided any arguments... +{ + stackTransformOffsets( 9 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/examples/index.js b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/examples/index.js new file mode 100644 index 000000000000..f8341e2cc40e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/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 contains = require( '@stdlib/array/base/assert/contains' ).factory; +var stackTransformOffsets = require( './../lib' ); + +var isStackTransformOffset = contains( stackTransformOffsets() ); + +var bool = isStackTransformOffset( 'center' ); +console.log( bool ); +// => true + +bool = isStackTransformOffset( 'normalize' ); +console.log( bool ); +// => true + +bool = isStackTransformOffset( 'zero' ); +console.log( bool ); +// => true + +bool = isStackTransformOffset( 'beep' ); +console.log( bool ); +// => false + +bool = isStackTransformOffset( 'boop' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/data.json b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/data.json new file mode 100644 index 000000000000..f40ca72aea6d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/data.json @@ -0,0 +1,5 @@ +[ + "center", + "normalize", + "zero" +] diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/index.js b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/index.js new file mode 100644 index 000000000000..e20897bd039c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/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 stack transform offsets. +* +* @module @stdlib/plot/vega/transform/stack/offsets +* +* @example +* var stackTransformOffsets = require( '@stdlib/plot/vega/transform/stack/offsets' ); +* +* var out = stackTransformOffsets(); +* // returns [ 'center', 'normalize', 'zero' ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/main.js b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/main.js new file mode 100644 index 000000000000..c0535119abed --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/lib/main.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'; + +// MODULES // + +var DATA = require( './data.json' ); + + +// MAIN // + +/** +* Returns a list of stack transform offsets. +* +* @returns {StringArray} list of stack transform offsets +* +* @example +* var out = offsets(); +* // returns [ 'center', 'normalize', 'zero' ] +*/ +function offsets() { + return DATA.slice(); +} + + +// EXPORTS // + +module.exports = offsets; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/package.json b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/package.json new file mode 100644 index 000000000000..83b86c050265 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/plot/vega/transform/stack/offsets", + "version": "0.0.0", + "description": "List of supported Vega stack transform offsets.", + "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", + "transform", + "stack", + "offset", + "offsets", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/test/test.js b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/test/test.js new file mode 100644 index 000000000000..ef2fc1f96290 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/stack/offsets/test/test.js @@ -0,0 +1,48 @@ +/** +* @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 stackTransformOffsets = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof stackTransformOffsets, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a list of stack transform offsets', function test( t ) { + var expected; + var actual; + + expected = [ + 'center', + 'normalize', + 'zero' + ]; + actual = stackTransformOffsets(); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +});