Skip to content

tomp4l/bs-typed-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bs-typed-array

Fairly similar binding to the TypedArray classes.

See BsTypedArray_TypedArray.rei for available bindings.

See the MDN web docs for the javascript interfaces these are based off. The interfaces are very similar to standard arrays.

Installation

npm install --save bs-typed-array

Then add bs-typed-array to bs-dependencies in your bsconfig.json:

{
  ...
  "bs-dependencies": ["bs-typed-array", ...]
}

Example

open BsTypedArray;

let array = TypedArray.from(TypedArray.Uint16, [|1, 3, 5, 6|]);

let copy = TypedArray.copyFromTypedArray(TypedArray.Int16, array);

let mapped = TypedArray.map(copy, (. a, _index) => - a);

Js.log(array);
Js.log(copy);
Js.log(mapped);
/**
 * Uint16Array [ 1, 3, 5, 6 ]
 * Int16Array [ 1, 3, 5, 6 ]
 * Int16Array [ -1, -3, -5, -6 ]
 */;

About

Bucklescript typed array bindings

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages