0.2.1 • Published 2 months ago

@stdlib/array-base-copy-indexed v0.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

copyIndexed

NPM version Build Status Coverage Status

Copy the elements of an indexed array-like object to a new "generic" array.

Installation

npm install @stdlib/array-base-copy-indexed

Usage

var copyIndexed = require( '@stdlib/array-base-copy-indexed' );

copyIndexed( x )

Copies the elements of an indexed array-like object to a new "generic" array.

var x = [ 1, 2, 3 ];

var out = copyIndexed( x );
// returns [ 1, 2, 3  ]

var bool = ( out === x );
// returns false

Notes

  • An indexed array-like object is a data structure in which one retrieves elements via integer indices using bracket [] notation (e.g., Float64Array, Int32Array, Array, etc). This is in contrast to an accessor array-like object in which one retrieves elements using get and set methods (e.g., Complex64Array and Complex128Array).

Examples

var filledBy = require( '@stdlib/array-filled-by' );
var randu = require( '@stdlib/random-base-randu' );
var copyIndexed = require( '@stdlib/array-base-copy-indexed' );

// Create a Float64Array:
var arr = filledBy( 10, 'float64', randu );

// Copy elements to a generic array:
var out = copyIndexed( arr );

// Retrieve the first element:
var x = out[ 0 ];
// returns <number>

console.log( '%d', x );

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.