From 4a9caea5cea39b89b57f7c6d01b19e33afba87d5 Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Fri, 17 Jul 2026 02:10:57 +0530 Subject: [PATCH] feat: add plot/vega/transform/label/anchor-directions --- 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_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - 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 --- --- .../label/anchor-directions/README.md | 117 ++++++++++++++++++ .../anchor-directions/benchmark/benchmark.js | 48 +++++++ .../label/anchor-directions/docs/repl.txt | 17 +++ .../anchor-directions/docs/types/index.d.ts | 35 ++++++ .../anchor-directions/docs/types/test.ts | 32 +++++ .../label/anchor-directions/examples/index.js | 40 ++++++ .../label/anchor-directions/lib/data.json | 11 ++ .../label/anchor-directions/lib/index.js | 40 ++++++ .../label/anchor-directions/lib/main.js | 44 +++++++ .../label/anchor-directions/package.json | 65 ++++++++++ .../label/anchor-directions/test/test.js | 54 ++++++++ 11 files changed, 503 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/README.md create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/data.json create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/package.json create mode 100644 lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/test/test.js diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/README.md b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/README.md new file mode 100644 index 000000000000..174bcdfc1e51 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/README.md @@ -0,0 +1,117 @@ + + +# labelAnchorDirections + +> List of supported Vega label transform anchor directions. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var labelAnchorDirections = require( '@stdlib/plot/vega/transform/label/anchor-directions' ); +``` + +#### labelAnchorDirections() + +Returns a list of label anchor directions. + +```javascript +var out = labelAnchorDirections(); +// returns [ 'bottom', 'bottom-left', 'bottom-right', 'left', 'middle', 'right', 'top', 'top-left', 'top-right' ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var labelAnchorDirections = require( '@stdlib/plot/vega/transform/label/anchor-directions' ); + +var isLabelAnchorDirection = contains( labelAnchorDirections() ); + +var bool = isLabelAnchorDirection( 'top-left' ); +// returns true + +bool = isLabelAnchorDirection( 'middle' ); +// returns true + +bool = isLabelAnchorDirection( 'beep' ); +// returns false + +bool = isLabelAnchorDirection( 'boop' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/benchmark/benchmark.js new file mode 100644 index 000000000000..8d48b8247278 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/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 labelAnchorDirections = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = labelAnchorDirections(); + 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(); +}); diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/repl.txt b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/repl.txt new file mode 100644 index 000000000000..ec4ca78ae2fe --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/repl.txt @@ -0,0 +1,17 @@ + +{{alias}}() + Returns a list of label anchor directions. + + Returns + ------- + out: Array + List of label anchor directions. + + Examples + -------- + > var out = {{alias}}() + [ 'bottom', 'bottom-left', 'bottom-right', ... ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/types/index.d.ts new file mode 100644 index 000000000000..c8e091e1273d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/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 label anchor directions. +* +* @returns list of label anchor directions +* +* @example +* var list = labelAnchorDirections(); +* // returns [ 'bottom', 'bottom-left', 'bottom-right', 'left', 'middle', 'right', 'top', 'top-left', 'top-right' ] +*/ +declare function labelAnchorDirections(): Array; + + +// EXPORTS // + +export = labelAnchorDirections; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/types/test.ts b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/docs/types/test.ts new file mode 100644 index 000000000000..e4236ad6f068 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/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 labelAnchorDirections = require( './index' ); + + +// TESTS // + +// The function returns an array of strings... +{ + labelAnchorDirections(); // $ExpectType string[] +} + +// The compiler throws an error if the function is provided any arguments... +{ + labelAnchorDirections( 9 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/examples/index.js b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/examples/index.js new file mode 100644 index 000000000000..62d1e23a127c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/examples/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'; + +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var labelAnchorDirections = require( './../lib' ); + +var isLabelAnchorDirection = contains( labelAnchorDirections() ); + +var bool = isLabelAnchorDirection( 'top-left' ); +console.log( bool ); +// => true + +bool = isLabelAnchorDirection( 'middle' ); +console.log( bool ); +// => true + +bool = isLabelAnchorDirection( 'beep' ); +console.log( bool ); +// => false + +bool = isLabelAnchorDirection( 'boop' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/data.json b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/data.json new file mode 100644 index 000000000000..30b312485ee2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/data.json @@ -0,0 +1,11 @@ +[ + "bottom", + "bottom-left", + "bottom-right", + "left", + "middle", + "right", + "top", + "top-left", + "top-right" +] diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/index.js b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/index.js new file mode 100644 index 000000000000..89c15414c6b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/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 label anchor directions. +* +* @module @stdlib/plot/vega/transform/label/anchor-directions +* +* @example +* var labelAnchorDirections = require( '@stdlib/plot/vega/transform/label/anchor-directions' ); +* +* var out = labelAnchorDirections(); +* // returns [ 'bottom', 'bottom-left', 'bottom-right', 'left', 'middle', 'right', 'top', 'top-left', 'top-right' ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/main.js b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/lib/main.js new file mode 100644 index 000000000000..77b69b8d4084 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/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 label anchor directions. +* +* @returns {StringArray} list of label anchor directions +* +* @example +* var out = labelAnchorDirections(); +* // returns [ 'bottom', 'bottom-left', 'bottom-right', 'left', 'middle', 'right', 'top', 'top-left', 'top-right' ] +*/ +function labelAnchorDirections() { + return DATA.slice(); +} + + +// EXPORTS // + +module.exports = labelAnchorDirections; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/package.json b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/package.json new file mode 100644 index 000000000000..9d17f085f0b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/plot/vega/transform/label/anchor-directions", + "version": "0.0.0", + "description": "List of supported Vega label transform anchor directions.", + "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", + "label", + "anchor", + "direction", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/test/test.js b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/test/test.js new file mode 100644 index 000000000000..75fb2ac1e629 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/anchor-directions/test/test.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var labelAnchorDirections = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof labelAnchorDirections, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a list of label anchor directions', function test( t ) { + var expected; + var actual; + + expected = [ + 'bottom', + 'bottom-left', + 'bottom-right', + 'left', + 'middle', + 'right', + 'top', + 'top-left', + 'top-right' + ]; + actual = labelAnchorDirections(); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +});