Arrays
Arrays.
Installation
npm install @stdlib/array
Usage
var ns = require( '@stdlib/array' );
ns
Arrays.
var o = ns;
The namespace exports the following array constructors:
ArrayBuffer( size )
: constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.Float32Array()
: typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.Float64Array()
: typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in the platform byte order.Int16Array()
: typed array constructor which returns a typed array representing an array of twos-complement 16-bit signed integers in the platform byte order.Int32Array()
: typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order.Int8Array()
: typed array constructor which returns a typed array representing an array of twos-complement 8-bit signed integers in the platform byte order.SharedArrayBuffer( size )
: constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory.Uint16Array()
: typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.Uint32Array()
: typed array constructor which returns a typed array representing an array of 32-bit unsigned integers in the platform byte order.Uint8Array()
: typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order.Uint8ClampedArray()
: typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.
var arr = new ns.Int32Array( 5 );
Alternatively, use the typedarray
function to create a typed array of a given data type:
var arr1 = ns.typedarray( 5 );
var arr2 = ns.typedarray( 5, 'uint8' );
The namespace contains functions to create arrays pre-filled with spaced values:
You can use the following functions to retrieve a list of available data types:
var DTYPES = ns.arrayDataTypes();
Furthermore, the namespace contains utility functions to retrieve a given constructor:
var ctor = ns.typedarrayCtors( 'float64' );
ctor = ns.typedarrayCtors( 'int' );
Lastly, the namespace contains various other functions for dealing with arrays, including functions to convert arrays from one data type to another or to serialize them as JSON and vice versa.
Complex128Array()
: 128-bit complex number array.Complex64Array()
: 64-bit complex number array.convertArraySame( x, y )
: convert an array to the same data type as a second input array.convertArray( arr, dtype )
: convert an array to an array of a different data type.DataView( buffer[, byteOffset[, byteLength]] )
: constructor which returns a data view representing a provided array buffer.arrayDataType( array )
: return the data type of an array.filledarray()
: create a filled array.iterator2array( iterator[, out][, mapFcn[, thisArg]] )
: create (or fill) an array from an iterator.arrayMinDataType( value )
: determine the minimum array data type of the closest "kind" necessary for storing a provided scalar value.arrayNextDataType( [dtype] )
: return the next larger array data type of the same kind.typedarraypool()
: allocate typed arrays from a typed array memory pool.arrayPromotionRules( [dtype1, dtype2] )
: return the array data type with the smallest size and closest "kind" to which array data types can be safely cast.reviveTypedArray( key, value )
: revive a JSON-serialized typed array.arraySafeCasts( [dtype] )
: return a list of array data types to which a provided array data type can be safely cast.arraySameKindCasts( [dtype] )
: return a list of array data types to which a provided array data type can be safely cast or cast within the same "kind".arrayShape( arr )
: determine (nested) array dimensions.circarray2iterator( src[, options][, mapFcn[, thisArg]] )
: create an iterator which repeatedly iterates over the elements of an array-like object.array2iteratorRight( src[, mapFcn[, thisArg]] )
: create an iterator from an array-like object, iterating from right to left.array2iterator( src[, mapFcn[, thisArg]] )
: create an iterator from an array-like object.typedarray2json( typedarray )
: return a JSON representation of a typed array.sparsearray2iteratorRight( src[, mapFcn[, thisArg]] )
: create an iterator from a sparse array-like object, iterating from right to left.sparsearray2iterator( src[, mapFcn[, thisArg]] )
: create an iterator from a sparse array-like object.stridedarray2iterator( N, src, stride, offset[, mapFcn[, thisArg]] )
: create an iterator from a strided array-like object.arrayview2iteratorRight( src[, begin[, end]][, mapFcn[, thisArg]] )
: create an iterator from an array-like object view, iterating from right to left.arrayview2iterator( src[, begin[, end]][, mapFcn[, thisArg]] )
: create an iterator from an array-like object view.
Examples
var objectKeys = require( '@stdlib/utils/keys' );
var ns = require( '@stdlib/array' );
console.log( objectKeys( ns ) );
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.
License
See LICENSE.
Copyright
Copyright © 2016-2021. The Stdlib Authors.
0.0.12 (2021-08-22)
No changes reported for this release.
</section>
<!-- /.release -->
<section class="release" id="v0.0.11">