npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stdlib/array-fixed-endian-float32

v0.1.0

Published

Float32Array having a specified byte order.

Downloads

39

Readme

Float32ArrayFE

NPM version Build Status Coverage Status

Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in a specified byte order.

In contrast to the Float32Array typed array constructor which stores values according to the host platform byte order, the Float32ArrayFE constructor allows 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.

Installation

npm install @stdlib/array-fixed-endian-float32

Usage

var Float32ArrayFE = require( '@stdlib/array-fixed-endian-float32' );

Float32ArrayFE( endianness )

A typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in a specified byte order.

var arr = new Float32ArrayFE( 'little-endian' );
// returns <Float32ArrayFE>

Float32ArrayFE( endianness, length )

Returns a typed array having a specified length and byte order.

var arr = new Float32ArrayFE( 'little-endian', 5 );
// returns <Float32ArrayFE>

Float32ArrayFE( endianness, typedarray )

Creates a typed array from another typed array.

var Float32Array = require( '@stdlib/array-float32' );

var arr1 = new Float32Array( [ 0.5, 0.5, 0.5 ] );
var arr2 = new Float32ArrayFE( 'little-endian', arr1 );
// returns <Float32ArrayFE>

var v = arr2.get( 0 );
// returns 0.5

Float32ArrayFE( endianness, obj )

Creates a typed array from an array-like object or iterable.

var arr = new Float32ArrayFE( 'little-endian', [ 0.5, 0.5, 0.5 ] );
// returns <Float32ArrayFE>

var v = arr.get( 0 );
// returns 0.5

Float32ArrayFE( endianness, buffer[, byteOffset[, length]] )

Returns a typed array view of an ArrayBuffer.

var ArrayBuffer = require( '@stdlib/array-buffer' );

var buf = new ArrayBuffer( 32 );
var arr = new Float32ArrayFE( 'little-endian', buf, 0, 4 );
// returns <Float32ArrayFE>

Properties

Float32ArrayFE.BYTES_PER_ELEMENT

Number of bytes per view element.

var nbytes = Float32ArrayFE.BYTES_PER_ELEMENT;
// returns 4

Float32ArrayFE.name

Typed array constructor name.

var str = Float32ArrayFE.name;
// returns 'Float32ArrayFE'

Float32ArrayFE.prototype.buffer

Read-only property which returns the ArrayBuffer referenced by the typed array.

var arr = new Float32ArrayFE( 'little-endian', 5 );
var buf = arr.buffer;
// returns <ArrayBuffer>

Float32ArrayFE.prototype.byteLength

Read-only property which returns the length (in bytes) of the typed array.

var arr = new Float32ArrayFE( 'little-endian', 5 );
var byteLength = arr.byteLength;
// returns 20

Float32ArrayFE.prototype.byteOffset

Read-only property which returns the offset (in bytes) of the typed array from the start of its ArrayBuffer.

var arr = new Float32ArrayFE( 'little-endian', 5 );
var byteOffset = arr.byteOffset;
// returns 0

Float32ArrayFE.prototype.BYTES_PER_ELEMENT

Number of bytes per view element.

var arr = new Float32ArrayFE( 'little-endian', 5 );
var nbytes = arr.BYTES_PER_ELEMENT;
// returns 4

Float32ArrayFE.prototype.length

Read-only property which returns the number of view elements.

var arr = new Float32ArrayFE( 'little-endian', 5 );
var len = arr.length;
// returns 5

Methods

Float32ArrayFE.from( endianness, src[, map[, thisArg]] )

Creates a new typed array from an array-like object or an iterable.

var arr = Float32ArrayFE.from( 'little-endian', [ 1.0, -1.0 ] );
// returns <Float32ArrayFE>

var v = arr.get( 0 );
// returns 1.0

To invoke a function for each src value, provide a callback function.

function mapFcn( v ) {
    return v * 2.0;
}

var arr = Float32ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn );
// returns <Float32ArrayFE>

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.

function mapFcn( v ) {
    this.count += 1;
    return v * 2.0;
}

var ctx = {
    'count': 0
};

var arr = Float32ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn, ctx );
// returns <Float32ArrayFE>

var v = arr.get( 0 );
// returns 2.0

var n = ctx.count;
// returns 2

Float32ArrayFE.of( endianness, element0[, element1[, ...elementN]] )

Creates a new typed array from a variable number of arguments.

var arr = Float32ArrayFE.of( 'little-endian', 1.0, -1.0 );
// returns <Float32ArrayFE>

var v = arr.get( 0 );
// returns 1.0

Float32ArrayFE.prototype.get( i )

Returns an array element located at a nonnegative integer position (index) i.

var arr = new Float32ArrayFE( 'little-endian', 10 );

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

var arr = new Float32ArrayFE( 'little-endian', 10 );

var v = arr.get( 100 );
// returns undefined

Float32ArrayFE.prototype.set( arr[, offset] )

Sets array elements.

var arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );
// returns <Float32ArrayFE>

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.

var arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );
// returns <Float32ArrayFE>

// 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 with the target array, the method will intelligently copy the source range to the destination range.

Float32ArrayFE.prototype.toString()

Serializes an array as a string.

var arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );

var str = arr.toString();
// returns '1,2,3'

Notes

  • The 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.
    • big-endian: store values such that bytes are stored from most-to-least significant bytes. This is the dominant ordering in network protocols.
  • While a Float32ArrayFE strives to maintain (but does not guarantee) consistency with typed arrays, significant deviations from ECMAScript-defined typed array behavior are as follows:

    • The constructor does 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

var Float32Array = require( '@stdlib/array-float32' );
var logEach = require( '@stdlib/console-log-each' );
var Float32ArrayFE = require( '@stdlib/array-fixed-endian-float32' );

// Create a typed array by specifying a length:
var out = new Float32ArrayFE( '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 Float32ArrayFE( 'big-endian', arr );
logEach( '%s', out );

// Create a typed array from an array buffer:
arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order
out = new Float32ArrayFE( 'little-endian', arr.buffer );
logEach( '%s', out );

// Create a typed array from an array buffer view:
arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order
out = new Float32ArrayFE( 'big-endian', arr.buffer, 8, 2 );
logEach( '%s', out );

See Also


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-2026. The Stdlib Authors.