uupaa.typedarray.js

0.5.4 • Public • Published

TypedArray.js Build Status

npm

TypedArray utility functions.

This module made of WebModule.

Documentation

Browser, NW.js and Electron

<script src="<module-dir>/lib/WebModule.js"></script>
<script src="<module-dir>/lib/TypedArray.js"></script>
<script>

TypedArray.BIG_ENDIAN                           // -> false (ARM, Intel CPU)
TypedArray.hton16( new Uint8Array([1,2]) )      // -> [2, 1]
TypedArray.ntoh16( new Uint8Array([1,2]) )      // -> [2, 1]
TypedArray.hton16( TypedArray.ntoh16( new Uint8Array([1,2]) ) ) // -> [1, 2]
TypedArray.expand( new Uint32Array([1,2,3]) )   // -> Uint32Array([1,2,3,0,0,0])
TypedArray.concat(new Uint8Array(10), new Uint8Array(20)) // -> new Uint8Array(30)

TypedArray.toString( new Uint8Array([0x33, 0x34, 0x35, 0x36]) ) // -> "3456"
TypedArray.fromString("Hello")                  // -> [72, 101, 108, 108, 111]
TypedArray.fromString("あいう")                 // -> [66, 68, 70]
TypedArray.fromString("あいう", Uint16Array)    // -> [12354, 12356, 12358]
</script>

WebWorkers

importScripts("<module-dir>lib/WebModule.js");
importScripts("<module-dir>lib/TypedArray.js");

Node.js

require("<module-dir>lib/WebModule.js");
require("<module-dir>lib/TypedArray.js");

Package Sidebar

Install

npm i uupaa.typedarray.js

Weekly Downloads

0

Version

0.5.4

License

MIT

Last publish

Collaborators

  • uupaa