array-fixed-endian-factory

Return a typed array constructor for creating typed arrays having a specified byte order.

https://github.com/stdlib-js/array-fixed-endian-factory

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.8%) to scientific vocabulary

Keywords

array big-endian byte-order data endian factory javascript little-endian node node-js nodejs stdlib structure typed typed-array types
Last synced: 6 months ago · JSON representation ·

Repository

Return a typed array constructor for creating typed arrays having a specified byte order.

Basic Info
Statistics
  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
array big-endian byte-order data endian factory javascript little-endian node node-js nodejs stdlib structure typed typed-array types
Created over 1 year ago · Last pushed 8 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security

README.md

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

fixedEndianFactory

NPM version Build Status Coverage Status <!-- dependencies -->

Return a typed array constructor for creating typed arrays having a specified byte order.

In contrast to built-in typed array constructors which store values according to the host platform byte order, the typed array constructors returned by the factory function allow enforcing a specific byte order. Such enforcement can be particularly advantageous when working with memory buffers which do not necessarily follow host platform byte order, such as [WebAssembly memory][@stdlib/wasm/memory].
## Installation ```bash npm install @stdlib/array-fixed-endian-factory ``` Alternatively, - To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm`][esm-url] branch (see [README][esm-readme]). - If you are using Deno, visit the [`deno`][deno-url] branch (see [README][deno-readme] for usage intructions). - For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd`][umd-url] branch (see [README][umd-readme]). The [branches.md][branches-url] file summarizes the available branches and displays a diagram illustrating their relationships. To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.
## Usage ```javascript var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); ``` #### fixedEndianFactory( dtype ) Returns a typed array constructor for creating typed arrays having a specified [data type][@stdlib/array/typed-dtypes] and byte order. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); // returns var Float32ArrayFE = fixedEndianFactory( 'float32' ); // returns ``` * * * ### Typed Array Constructor #### TypedArrayFE( endianness ) A typed array constructor which returns a typed array representing values stored in a specified byte order. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian' ); // returns ``` #### TypedArrayFE( endianness, length ) Returns a typed array having a specified length and byte order. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 5 ); // returns ``` #### TypedArrayFE( endianness, typedarray ) Creates a typed array from another typed array. ```javascript var Float32Array = require( '@stdlib/array-float32' ); var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr1 = new Float32Array( [ 0.5, 0.5, 0.5 ] ); var arr2 = new Float64ArrayFE( 'little-endian', arr1 ); // returns var v = arr2.get( 0 ); // returns 0.5 ``` #### TypedArrayFE( endianness, obj ) Creates a typed array from an array-like object or iterable. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 0.5, 0.5, 0.5 ] ); // returns var v = arr.get( 0 ); // returns 0.5 ``` #### TypedArrayFE( endianness, buffer\[, byteOffset\[, length]] ) Returns a typed array view of an [`ArrayBuffer`][@stdlib/array/buffer]. ```javascript var ArrayBuffer = require( '@stdlib/array-buffer' ); var Float64ArrayFE = fixedEndianFactory( 'float64' ); var buf = new ArrayBuffer( 32 ); var arr = new Float64ArrayFE( 'little-endian', buf, 0, 4 ); // returns ``` * * * ### Typed Array Properties #### TypedArrayFE.BYTES_PER_ELEMENT Number of bytes per view element. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var nbytes = Float64ArrayFE.BYTES_PER_ELEMENT; // returns 8 ``` #### TypedArrayFE.name Typed array constructor name. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var str = Float64ArrayFE.name; // returns 'Float64ArrayFE' ``` #### TypedArrayFE.prototype.buffer **Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the typed array. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 5 ); var buf = arr.buffer; // returns ``` #### TypedArrayFE.prototype.byteLength **Read-only** property which returns the length (in bytes) of the typed array. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 5 ); var byteLength = arr.byteLength; // returns 40 ``` #### TypedArrayFE.prototype.byteOffset **Read-only** property which returns the offset (in bytes) of the typed array from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 5 ); var byteOffset = arr.byteOffset; // returns 0 ``` #### TypedArrayFE.prototype.BYTES_PER_ELEMENT Number of bytes per view element. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 5 ); var nbytes = arr.BYTES_PER_ELEMENT; // returns 8 ``` #### TypedArrayFE.prototype.length **Read-only** property which returns the number of view elements. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 5 ); var len = arr.length; // returns 5 ``` * * * ### Typed Array Methods #### TypedArrayFE.from( endianness, src\[, map\[, thisArg]] ) Creates a new typed array from an array-like object or an iterable. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = Float64ArrayFE.from( 'little-endian', [ 1.0, -1.0 ] ); // returns var v = arr.get( 0 ); // returns 1.0 ``` To invoke a function for each `src` value, provide a callback function. ```javascript function mapFcn( v ) { return v * 2.0; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = Float64ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn ); // returns var v = arr.get( 0 ); // returns 2.0 ``` A callback function is provided two arguments: - **value**: source value. - **index**: source index. To set the callback execution context, provide a `thisArg`. ```javascript function mapFcn( v ) { this.count += 1; return v * 2.0; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var ctx = { 'count': 0 }; var arr = Float64ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn, ctx ); // returns var v = arr.get( 0 ); // returns 2.0 var n = ctx.count; // returns 2 ``` #### TypedArrayFE.of( endianness, element0\[, element1\[, ...elementN]] ) Creates a new typed array from a variable number of arguments. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = Float64ArrayFE.of( 'little-endian', 1.0, -1.0 ); // returns var v = arr.get( 0 ); // returns 1.0 ``` #### TypedArrayFE.prototype.at( i ) Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); // returns var out = arr.at( 0 ); // returns 1.0 out = arr.at( -1 ); // returns 3.0 ``` If provided an out-of-bounds index, the method returns `undefined`. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); // returns var v = arr.at( 100 ); // returns undefined v = arr.at( -100 ); // returns undefined ``` #### TypedArrayFE.prototype.every( predicate\[, thisArg] ) Tests whether all the elements in an array pass a test implemented by a predicate function. ```javascript function isNegative( v ) { return v < 0; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ -1.0, -2.0, -3.0, -4.0 ] ); // returns var bool = arr.every( isNegative ); // returns true ``` The `predicate` function is provided three arguments: - **value**: current array element. - **index**: current array element index. - **arr**: the array on which this method was called. To set the function execution context, provide a `thisArg`. ```javascript function isPositive( v, i ) { this.count += 1; return v > 0; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, -3.0 ] ); // returns var context = { 'count': 0 }; var bool = arr.every( isPositive, context ); // returns false var count = context.count; // returns 3 ``` #### TypedArrayFE.prototype.filter( predicate\[, thisArg] ) Returns a new array containing the elements of an array which pass a test implemented by a predicate function. ```javascript function predicate( v ) { return ( v % 2 === 0 ); } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); var out = arr.filter( predicate ); // returns var len = out.length; // returns 2 var v = out.get( 0 ); // returns 2.0 v = out.get( 1 ); // return 4.0 ``` The `predicate` function is provided three arguments: - **value**: current array element. - **index**: current array element index. - **arr**: the array on which this method was called. To set the function execution context, provide a `thisArg`. ```javascript function predicate( v, i ) { this.count += 1; return ( v % 2 === 0 ); } var context = { 'count': 0 }; var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); var out = arr.filter( predicate, context ); // returns var len = out.length; // returns 2 var count = context.count; // returns 4 ``` #### TypedArrayFE.prototype.forEach( callbackFn\[, thisArg] ) Invokes a function once for each array element. ```javascript function log( v, i ) { console.log( '%s: %s', i.toString(), v.toString() ); } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 3 ); // returns arr.set( 1.5, 0 ); arr.set( 2.5, 1 ); arr.set( 3.5, 2 ); arr.forEach( log ); /* => 0: 1.5 1: 2.5 2: 3.5 */ ``` The invoked function is provided three arguments: - **value**: current array element. - **index**: current array element index. - **arr**: the array on which this method was called. To set the function execution context, provide a `thisArg`. ```javascript function fcn( v, i ) { this.count += 1; console.log( '%s: %s', i.toString(), v.toString() ); } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 3 ); // returns var context = { 'count': 0 }; arr.set( 1.0, 0 ); arr.set( 2.0, 1 ); arr.set( 3.0, 2 ); arr.forEach( fcn, context ); var count = context.count; // returns 3 ``` #### TypedArrayFE.prototype.get( i ) Returns an array element located at a nonnegative integer position (index) `i`. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 10 ); // returns // Set the first element: arr.set( 1.0, 0 ); // Get the first element: var v = arr.get( 0 ); // returns 1.0 ``` If provided an out-of-bounds index, the method returns `undefined`. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 10 ); // returns var v = arr.get( 100 ); // returns undefined ``` #### TypedArrayFE.prototype.includes( searchElement\[, fromIndex] ) Returns a boolean indicating whether an array includes a provided value. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); var idx = arr.includes( 2.0 ); // returns true idx = arr.includes( 2.0, 2 ); // returns true idx = arr.includes( 2.0, -4 ); // returns true idx = arr.includes( 5.0 ); // returns false ``` #### TypedArrayFE.prototype.indexOf( searchElement\[, fromIndex] ) Returns the first index at which a given element can be found. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); var idx = arr.indexOf( 2.0 ); // returns 1 idx = arr.indexOf( 2.0, 2 ); // returns 4 idx = arr.indexOf( 2.0, -4 ); // returns 1 ``` If `searchElement` is not present in the array, the method returns `-1`. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); var idx = arr.indexOf( 5.0 ); // returns -1 ``` #### TypedArrayFE.prototype.lastIndexOf( searchElement\[, fromIndex] ) Returns the last index at which a given element can be found in the array. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); var idx = arr.lastIndexOf( 2.0 ); // returns 4 idx = arr.lastIndexOf( 2.0, 3 ); // returns 1 idx = arr.lastIndexOf( 2.0, -2 ); // returns 1 ``` If `searchElement` is not present in the array, the method returns `-1`. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); var idx = arr.lastIndexOf( 5.0 ); // returns -1 ``` #### TypedArray.prototype.map( callbackFn\[, thisArg] ) Returns a new array with each element being the result of a provided callback function. ```javascript function fcn( v ) { return -v; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); // returns var out = arr.map( fcn ); // returns var z = out.get( 0 ); // returns -1.0 z = out.get( 1 ); // returns -2.0 z = out.get( 2 ); // returns -3.0 ``` The callback function is provided three arguments: - **value**: current array element. - **index**: current array element index. - **arr**: the array on which this method was called. To set the function execution context, provide a `thisArg`. ```javascript function fcn( v, i ) { this.count += i; return -v; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', 3 ); arr.set( -1.0, 0 ); arr.set( 1.0, 1 ); arr.set( -1.0, 2 ); var context = { 'count': 0 }; var out = arr.map( fcn, context ); // returns var count = context.count; // returns 3; ``` #### TypedArray.prototype.reduce( reducerFn\[, initialValue] ) Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. ```javascript function reducer( acc, v ) { return ( acc && v ); } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] ); // returns var out = arr.reduce( reducer ); // returns 0.0 ``` The reducer function is provided four arguments: - **acc**: accumulated result. - **value**: current array element. - **index**: current array element index. - **arr**: the array on which this method was called. By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. ```javascript function reducer( acc, v ) { if ( v ) { return acc + 1; } return acc; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] ); // returns var out = arr.reduce( reducer, 0 ); // returns 2 ``` #### TypedArray.prototype.reduceRight( reducerFn\[, initialValue] ) Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. ```javascript function reducer( acc, v ) { return ( acc && v ); } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] ); // returns var out = arr.reduceRight( reducer ); // returns 0.0 ``` The reducer function is provided four arguments: - **acc**: accumulated result. - **value**: current array element. - **index**: current array element index. - **arr**: the array on which this method was called. By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. ```javascript function reducer( acc, v ) { if ( v ) { return acc + 1; } return acc; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] ); // returns var out = arr.reduceRight( reducer, 0 ); // returns 2 ``` #### TypedArrayFE.prototype.set( arr\[, offset] ) Sets array elements. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); // returns var v = arr.get( 0 ); // returns 1.0 v = arr.get( 1 ); // returns 2.0 // Set the first two array elements: arr.set( [ 4.0, 5.0 ] ); v = arr.get( 0 ); // returns 4.0 v = arr.get( 1 ); // returns 5.0 ``` By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); // returns // Set the last two array elements: arr.set( [ 4.0, 5.0 ], 1 ); var v = arr.get( 1 ); // returns 4.0 v = arr.get( 2 ); // returns 5.0 ``` A few notes: - If `i` is out-of-bounds, the method throws an error. - If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. - If provided a typed array which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. #### TypedArrayFE.prototype.some( predicate\[, thisArg] ) Tests whether at least one element in an array passes a test implemented by a predicate function. ```javascript function isPositive( v ) { return v > 0; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ -1.0, 2.0, -3.0, -4.0 ] ); // returns var bool = arr.some( isPositive ); // returns true ``` The `predicate` function is provided three arguments: - **value**: current array element. - **index**: current array element index. - **arr**: the array on which this method was called. To set the function execution context, provide a `thisArg`. ```javascript function isPositive( v, i ) { this.count += 1; return v > 0; } var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ -1.0, -2.0, -3.0 ] ); // returns var context = { 'count': 0 }; var bool = arr.some( isPositive, context ); // returns false var count = context.count; // returns 3 ``` #### TypedArrayFE.prototype.toString() Serializes an array as a string. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); // returns var str = arr.toString(); // returns '1,2,3' ``` #### TypedArrayFE.prototype.join( \[separator] ) Returns a new string by concatenating all array elements. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); var str = arr.join(); // returns '1,2,3' ``` By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); var str = arr.join( ' - ' ); // returns '1 - 2 - 3' ``` #### TypedArrayFE.prototype.with( index, value ) Returns a new typed array with the element at a provided index replaced with a provided value. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); // returns var out = arr.with( 0, 0.0 ); // returns var v = out.get( 0 ); // returns 0.0 ```
* * * ## Notes - A returned constructor supports the following byte orders: - **little-endian**: store values such that bytes are stored from least-to-most significant bytes. This is the dominant ordering for processor architectures and their associated memory. This is also the ordering for [WebAssembly memory][@stdlib/wasm/memory]. - **big-endian**: store values such that bytes are stored from most-to-least significant bytes. This is the dominant ordering in network protocols. - While returned constructors _strive_ to maintain (but do not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - Constructors do **not** require the `new` operator. - Accessing array elements using bracket syntax (e.g., `X[i]`) is **not** supported. Instead, one **must** use the `.get()` method.
* * * ## Examples ```javascript var Float64Array = require( '@stdlib/array-float64' ); var logEach = require( '@stdlib/console-log-each' ); var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); var Float64ArrayFE = fixedEndianFactory( 'float64' ); // Create a typed array by specifying a length: var out = new Float64ArrayFE( 'little-endian', 3 ); logEach( '%s', out ); // Create a typed array from an array: var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; out = new Float64ArrayFE( 'big-endian', arr ); logEach( '%s', out ); // Create a typed array from an array buffer: arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order out = new Float64ArrayFE( 'little-endian', arr.buffer ); logEach( '%s', out ); // Create a typed array from an array buffer view: arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order out = new Float64ArrayFE( 'big-endian', arr.buffer, 8, 2 ); logEach( '%s', out ); ```
* * * ## Notice This package is part of [stdlib][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][stdlib], see the main project [repository][stdlib]. #### Community [![Chat][chat-image]][chat-url] --- ## License See [LICENSE][stdlib-license]. ## Copyright Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors].

Owner

  • Name: stdlib
  • Login: stdlib-js
  • Kind: organization

Standard library for JavaScript.

Citation (CITATION.cff)

cff-version: 1.2.0
title: stdlib
message: >-
  If you use this software, please cite it using the
  metadata from this file.

type: software

authors:
  - name: The Stdlib Authors
    url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
  Standard library for JavaScript and Node.js.

keywords:
  - JavaScript
  - Node.js
  - TypeScript
  - standard library
  - scientific computing
  - numerical computing
  - statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016

GitHub Events

Total
  • Push event: 104
Last Year
  • Push event: 104

Dependencies

.github/workflows/benchmark.yml actions
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 composite
.github/workflows/cancel.yml actions
  • styfle/cancel-workflow-action 85880fa0301c86cca9da44039ee3bb12d3bedbfa composite
.github/workflows/close_pull_requests.yml actions
  • superbrothers/close-pull-request 9c18513d320d7b2c7185fb93396d0c664d5d8448 composite
.github/workflows/examples.yml actions
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 composite
.github/workflows/npm_downloads.yml actions
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 composite
  • actions/upload-artifact 5d5d22a31266ced268874388b861e4b58bb5c2f3 composite
  • distributhor/workflow-webhook 48a40b380ce4593b6a6676528cd005986ae56629 composite
.github/workflows/productionize.yml actions
  • 8398a7/action-slack 28ba43ae48961b90635b50953d216767a6bea486 composite
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 composite
  • stdlib-js/bundle-action main composite
  • stdlib-js/transform-errors-action main composite
.github/workflows/publish.yml actions
  • 8398a7/action-slack 28ba43ae48961b90635b50953d216767a6bea486 composite
  • JS-DevTools/npm-publish 19c28f1ef146469e409470805ea4279d47c3d35c composite
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 composite
  • styfle/cancel-workflow-action 85880fa0301c86cca9da44039ee3bb12d3bedbfa composite
.github/workflows/test.yml actions
  • 8398a7/action-slack 28ba43ae48961b90635b50953d216767a6bea486 composite
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 composite
.github/workflows/test_bundles.yml actions
  • 8398a7/action-slack 28ba43ae48961b90635b50953d216767a6bea486 composite
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 composite
  • denoland/setup-deno 041b854f97b325bd60e53e9dc2de9cb9f9ac0cba composite
.github/workflows/test_coverage.yml actions
  • 8398a7/action-slack 28ba43ae48961b90635b50953d216767a6bea486 composite
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 composite
  • codecov/codecov-action 84508663e988701840491b86de86b666e8a86bed composite
  • distributhor/workflow-webhook 48a40b380ce4593b6a6676528cd005986ae56629 composite
.github/workflows/test_install.yml actions
  • 8398a7/action-slack 28ba43ae48961b90635b50953d216767a6bea486 composite
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 composite
package.json npm
  • @stdlib/array-float64 ^0.2.2 development
  • @stdlib/array-zero-to ^0.2.2 development
  • @stdlib/assert-has-own-property ^0.2.2 development
  • @stdlib/assert-is-number ^0.2.2 development
  • @stdlib/bench-harness ^0.2.2 development
  • @stdlib/console-log-each ^0.2.2 development
  • @stdlib/math-base-assert-is-nan ^0.2.2 development
  • @stdlib/math-base-special-pow ^0.3.0 development
  • @stdlib/random-array-randu ^0.2.1 development
  • istanbul ^0.4.1 development
  • tap-min git+https://github.com/Planeshifter/tap-min.git development
  • tape git+https://github.com/kgryte/tape.git#fix/globby development
  • @stdlib/array-base-accessor-getter ^0.2.2
  • @stdlib/array-base-assert-contains ^0.2.2
  • @stdlib/array-base-assert-is-byte-order github:stdlib-js/array-base-assert-is-byte-order#main
  • @stdlib/array-base-getter ^0.2.2
  • @stdlib/array-buffer ^0.2.2
  • @stdlib/array-dataview ^0.2.2
  • @stdlib/assert-has-iterator-symbol-support ^0.2.2
  • @stdlib/assert-is-arraybuffer ^0.2.2
  • @stdlib/assert-is-collection ^0.2.2
  • @stdlib/assert-is-function ^0.2.2
  • @stdlib/assert-is-nonnegative-integer ^0.2.2
  • @stdlib/assert-is-object ^0.2.2
  • @stdlib/assert-is-prototype-of ^0.2.2
  • @stdlib/assert-is-string ^0.2.2
  • @stdlib/error-tools-fmtprodmsg ^0.2.2
  • @stdlib/ndarray-base-bytes-per-element ^0.2.2
  • @stdlib/string-base-capitalize ^0.3.0
  • @stdlib/string-base-lowercase ^0.4.0
  • @stdlib/string-format ^0.2.2
  • @stdlib/symbol-iterator ^0.2.2
  • @stdlib/utils-define-nonenumerable-read-only-accessor ^0.2.3
  • @stdlib/utils-define-nonenumerable-read-only-property ^0.2.2