Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions lib/node_modules/@stdlib/plot/base/symbols2aliases/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<!--

@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.

-->

# symbols2aliases

> Convert an array of symbol [aliases][@stdlib/plot/base/symbol-aliases] and/or [shorthands][@stdlib/plot/base/symbol-shorthands] to canonical [symbol aliases][@stdlib/plot/base/symbol-aliases].

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var symbols2aliases = require( '@stdlib/plot/base/symbols2aliases' );
```

#### symbols2aliases( symbols )

Converts an array of symbol [aliases][@stdlib/plot/base/symbol-aliases] and/or [shorthands][@stdlib/plot/base/symbol-shorthands] to canonical [symbol aliases][@stdlib/plot/base/symbol-aliases].

```javascript
var out = symbols2aliases( [ 'o', 's' ] );
// returns [ 'circle', 'square' ]
```

If unable to resolve an alias for an element of the input array, the corresponding element in the output array is `null`.

```javascript
var out = symbols2aliases( [ 'o', 'beep' ] );
// returns [ 'circle', null ]
```

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var logEach = require( '@stdlib/console/log-each' );
var symbolAliases = require( '@stdlib/plot/base/symbol-aliases' );
var symbols2aliases = require( '@stdlib/plot/base/symbols2aliases' );

var symbols = symbolAliases();

logEach( '%s => %s', symbols, symbols2aliases( symbols ) );
```

</section>

<!-- /.examples -->

<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[@stdlib/plot/base/symbol-aliases]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/plot/base/symbol-aliases

[@stdlib/plot/base/symbol-shorthands]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/plot/base/symbol-shorthands

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -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 bench = require( '@stdlib/bench' );
var isArray = require( '@stdlib/assert/is-array' );
var pkg = require( './../package.json' ).name;
var symbols2aliases = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var values;
var out;
var i;

values = [
[ 'o', '+' ],
[ 'circle', 'triangle-up' ]
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = symbols2aliases( values[ i%values.length ] );
if ( out.length !== 2 ) {
b.fail( 'should return an array' );
}
}
b.toc();
if ( !isArray( out ) ) {
b.fail( 'should return an array' );
}
b.pass( 'benchmark finished' );
b.end();
});
28 changes: 28 additions & 0 deletions lib/node_modules/@stdlib/plot/base/symbols2aliases/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

{{alias}}( symbols )
Converts an array of symbol aliases and/or shorthands to canonical symbol
aliases.

If unable to resolve an alias for an element of the input array, the
corresponding element in the output array is `null`.

Parameters
----------
symbols: Array<string>
Symbol aliases and/or shorthands.

Returns
-------
out: Array
Canonical symbol aliases.

Examples
--------
> var v = {{alias}}( [ 'o', 's' ] )
[ 'circle', 'square' ]
> v = {{alias}}( [ 'o', 'beep' ] )
[ 'circle', null ]

See Also
--------

Original file line number Diff line number Diff line change
@@ -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

/// <reference types="@stdlib/types"/>

import { Collection } from '@stdlib/types/array';

/**
* Converts an array of symbol aliases and/or shorthands to canonical symbol aliases.
*
* ## Notes
*
* - If unable to resolve an alias for an element of the input array, the corresponding element in the output array is `null`.
*
* @param symbols - symbol aliases and/or shorthands
* @returns canonical symbol aliases
*
* @example
* var v = symbols2aliases( [ 'o', 's' ] );
* // returns [ 'circle', 'square' ]
*
* v = symbols2aliases( [ 'o', 'beep' ] );
* // returns [ 'circle', null ]
*/
declare function symbols2aliases( symbols: Collection<string> ): Array<string | null>;


// EXPORTS //

export = symbols2aliases;
Original file line number Diff line number Diff line change
@@ -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.
*/

import symbols2aliases = require( './index' );


// TESTS //

// The function returns an array...
{
symbols2aliases( [ 'o', '+' ] ); // $ExpectType (string | null)[]
}

// The compiler throws an error if the function is not provided a collection of strings...
{
symbols2aliases( 1 ); // $ExpectError
symbols2aliases( true ); // $ExpectError
symbols2aliases( false ); // $ExpectError
symbols2aliases( null ); // $ExpectError
symbols2aliases( undefined ); // $ExpectError
symbols2aliases( {} ); // $ExpectError
symbols2aliases( ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
symbols2aliases(); // $ExpectError
symbols2aliases( [ 'o' ], {} ); // $ExpectError
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @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 logEach = require( '@stdlib/console/log-each' );
var symbolAliases = require( '@stdlib/plot/base/symbol-aliases' );
var symbols2aliases = require( './../lib' );

var symbols = symbolAliases();

logEach( '%s => %s', symbols, symbols2aliases( symbols ) );
43 changes: 43 additions & 0 deletions lib/node_modules/@stdlib/plot/base/symbols2aliases/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @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';

/**
* Convert an array of symbol aliases and/or shorthands to canonical symbol aliases.
*
* @module @stdlib/plot/base/symbols2aliases
*
* @example
* var symbols2aliases = require( '@stdlib/plot/base/symbols2aliases' );
*
* var v = symbols2aliases( [ 'o', 's' ] );
* // returns [ 'circle', 'square' ]
*
* v = symbols2aliases( [ 'o', 'beep' ] );
* // returns [ 'circle', null ]
*/

// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
Loading