🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@stdlib/array-base-accessor-getter

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/array-base-accessor-getter - npm Package Compare versions

Comparing version
0.1.0
to
0.2.0
+5
SECURITY.md
# Security
> Policy for reporting security vulnerabilities.
See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
+1
-1
{
"version": 3,
"sources": ["../lib/main.js", "../lib/index.js"],
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'complex128': getComplex128,\n\t'complex64': getComplex64,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n* var real = require( '@stdlib/complex-real' );\n* var imag = require( '@stdlib/complex-imag' );\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex128( arr, 1 );\n* // returns <Complex128>\n*\n* var re = real( v );\n* // returns 3.0\n*\n* var im = imag( v );\n* // returns 4.0\n*/\nfunction getComplex128( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex64( arr, 1 );\n* // returns <Complex64>\n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getComplex64( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n* var dtype = require( '@stdlib/array-dtype' );\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 1 );\n* // returns <Complex64>\n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an accessor function for retrieving an element from an array-like object supporting the get/set protocol.\n*\n* @module @stdlib/array-base-accessor-getter\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n* var dtype = require( '@stdlib/array-dtype' );\n* var get = require( '@stdlib/array-base-accessor-getter' );\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 1 );\n* // returns <Complex64>\n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'complex128': getComplex128,\n\t'complex64': getComplex64,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n* var real = require( '@stdlib/complex-real' );\n* var imag = require( '@stdlib/complex-imag' );\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex128( arr, 1 );\n* // returns <Complex128>\n*\n* var re = real( v );\n* // returns 3.0\n*\n* var im = imag( v );\n* // returns 4.0\n*/\nfunction getComplex128( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex64( arr, 1 );\n* // returns <Complex64>\n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getComplex64( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n* var dtype = require( '@stdlib/array-dtype' );\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 1 );\n* // returns <Complex64>\n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an accessor function for retrieving an element from an array-like object supporting the get/set protocol.\n*\n* @module @stdlib/array-base-accessor-getter\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n* var dtype = require( '@stdlib/array-dtype' );\n* var getter = require( '@stdlib/array-base-accessor-getter' );\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 1 );\n* // returns <Complex64>\n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,CACb,WAAcC,EACd,UAAaC,EACb,QAAWC,CACZ,EA6BA,SAASF,EAAeG,EAAKC,EAAM,CAClC,OAAOD,EAAI,IAAKC,CAAI,CACrB,CA0BA,SAASH,EAAcE,EAAKC,EAAM,CACjC,OAAOD,EAAI,IAAKC,CAAI,CACrB,CA2BA,SAASF,EAAcC,EAAKC,EAAM,CACjC,OAAOD,EAAI,IAAKC,CAAI,CACrB,CA6BA,SAASC,EAAQC,EAAQ,CACxB,IAAIC,EAAIR,EAASO,CAAM,EACvB,OAAK,OAAOC,GAAM,WACVA,EAEDR,EAAQ,OAChB,CAKAD,EAAO,QAAUO,IC3GjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
"names": ["require_main", "__commonJSMin", "exports", "module", "GETTERS", "getComplex128", "getComplex64", "getArrayLike", "arr", "idx", "getter", "dtype", "f", "main"]
}

@@ -29,4 +29,3 @@ /*

*
* @param
arr - input array
* @param arr - input array
* @param idx - element index

@@ -62,5 +61,5 @@ * @returns element value

* @example
* var Complex128Array = require( `@stdlib/array/complex128` );
* var real = require( `@stdlib/array/real` );
* var imag = require( `@stdlib/array/imag` );
* var Complex128Array = require( '@stdlib/array-complex128' );
* var real = require( '@stdlib/array-real' );
* var imag = require( '@stdlib/array-imag' );
*

@@ -88,5 +87,5 @@ * var arr = new Complex128Array( [ 1, 2, 3, 4 ] );

* @example
* var Complex64Array = require( `@stdlib/array/complex64` );
* var realf = require( `@stdlib/array/realf` );
* var imagf = require( `@stdlib/array/imagf` );
* var Complex64Array = require( '@stdlib/array-complex64' );
* var realf = require( '@stdlib/array-realf' );
* var imagf = require( '@stdlib/array-imagf' );
*

@@ -131,3 +130,3 @@ * var arr = new Complex64Array( [ 1, 2, 3, 4 ] );

*/
declare function getter<T = unknown>( dtype: string ): GetArrayLike<T>; // tslint:disable-line:no-unnecessary-generics
declare function getter<T = unknown>( dtype: string ): GetArrayLike<T>;

@@ -134,0 +133,0 @@

@@ -31,3 +31,3 @@ /**

* var dtype = require( '@stdlib/array-dtype' );
* var get = require( '@stdlib/array-base-accessor-getter' );
* var getter = require( '@stdlib/array-base-accessor-getter' );
*

@@ -34,0 +34,0 @@ * var arr = new Complex64Array( [ 1, 2, 3, 4 ] );

+1
-1

@@ -1,1 +0,1 @@

Copyright (c) 2016-2023 The Stdlib Authors.
Copyright (c) 2016-2024 The Stdlib Authors.
{
"name": "@stdlib/array-base-accessor-getter",
"version": "0.1.0",
"version": "0.2.0",
"description": "Return an accessor function for retrieving an element from an array-like object supporting the get/set protocol.",

@@ -40,22 +40,23 @@ "license": "Apache-2.0",

"dependencies": {
"@stdlib/types": "^0.1.0"
"@stdlib/types": "^0.3.1"
},
"devDependencies": {
"@stdlib/array-base-zero-to": "^0.1.0",
"@stdlib/array-complex128": "^0.0.6",
"@stdlib/array-complex64": "^0.0.6",
"@stdlib/array-dtype": "^0.0.6",
"@stdlib/array-filled-by": "^0.0.2",
"@stdlib/assert-is-function": "^0.1.0",
"@stdlib/bench": "^0.1.0",
"@stdlib/complex-imag": "^0.1.0",
"@stdlib/complex-imagf": "^0.1.0",
"@stdlib/complex-real": "^0.1.0",
"@stdlib/complex-realf": "^0.1.0",
"@stdlib/math-base-assert-is-nan": "^0.1.0",
"@stdlib/math-base-assert-is-nanf": "^0.1.0",
"@stdlib/random-base-discrete-uniform": "^0.0.6",
"@stdlib/array-complex128": "^0.1.0",
"@stdlib/array-complex64": "^0.1.0",
"@stdlib/array-dtype": "^0.1.0",
"@stdlib/array-filled-by": "^0.1.0",
"@stdlib/assert-is-function": "^0.2.0",
"@stdlib/complex-imag": "^0.2.0",
"@stdlib/complex-imagf": "^0.2.0",
"@stdlib/complex-real": "^0.2.0",
"@stdlib/complex-realf": "^0.2.0",
"@stdlib/math-base-assert-is-nan": "^0.2.0",
"@stdlib/math-base-assert-is-nanf": "^0.2.0",
"@stdlib/random-base-discrete-uniform": "^0.1.0",
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
"istanbul": "^0.4.1",
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
"@stdlib/bench-harness": "^0.2.0",
"@stdlib/bench": "^0.3.1"
},

@@ -62,0 +63,0 @@ "engines": {

@@ -189,3 +189,3 @@ <!--

Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].

@@ -203,4 +203,4 @@ </section>

[test-image]: https://github.com/stdlib-js/array-base-accessor-getter/actions/workflows/test.yml/badge.svg?branch=v0.1.0
[test-url]: https://github.com/stdlib-js/array-base-accessor-getter/actions/workflows/test.yml?query=branch:v0.1.0
[test-image]: https://github.com/stdlib-js/array-base-accessor-getter/actions/workflows/test.yml/badge.svg?branch=v0.2.0
[test-url]: https://github.com/stdlib-js/array-base-accessor-getter/actions/workflows/test.yml?query=branch:v0.2.0

@@ -228,4 +228,7 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-base-accessor-getter/main.svg

[deno-url]: https://github.com/stdlib-js/array-base-accessor-getter/tree/deno
[deno-readme]: https://github.com/stdlib-js/array-base-accessor-getter/blob/deno/README.md
[umd-url]: https://github.com/stdlib-js/array-base-accessor-getter/tree/umd
[umd-readme]: https://github.com/stdlib-js/array-base-accessor-getter/blob/umd/README.md
[esm-url]: https://github.com/stdlib-js/array-base-accessor-getter/tree/esm
[esm-readme]: https://github.com/stdlib-js/array-base-accessor-getter/blob/esm/README.md
[branches-url]: https://github.com/stdlib-js/array-base-accessor-getter/blob/main/branches.md

@@ -235,3 +238,3 @@

[@stdlib/array/dtypes]: https://www.npmjs.com/package/@stdlib/stdlib
[@stdlib/array/dtypes]: https://www.npmjs.com/package/@stdlib/array-dtypes

@@ -238,0 +241,0 @@ </section>

Sorry, the diff of this file is not supported yet