babel-plugin-multidimensional-array
Fast multidimensional typed arrays with a nice syntax
Last updated 3 years ago by devongovett .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-multidimensional-array 
SYNC missed versions from official npm registry.

babel-plugin-multidimensional-array

Fast multidimensional typed arrays with a nice syntax.

Typed arrays are awesome, but sometimes you want a multidimensional array. You can do it with arrays of (arrays of...) typed arrays, but accessing or writing data to nested array objects is slow.

One way to fix this is by using a single flattened typed array, and hand calculating the offset where the data is for every access. But that is tedious. This babel plugin takes care of it for you. Just define your local variables or function arguments with dimensions, and accesses will be transformed to compute the correct offset.

Example

Compiles this:

let x[2][3] = new Uint8Array([1,2,3,4,5,6]);
x[1][2] = 42;

into:

let x = new Uint8Array([1,2,3,4,5,6]);
x[5] = 42;

Function arguments are also supported, as are non-constant dimensions:

function test(x[a][b], y) {
  x[1][y] = 4;
}

compiles to:

function test(x, y) {
  x[y + b * 1] = 4;
}

Licence

MIT

Current Tags

  • 1.0.0                                ...           latest (3 years ago)

1 Versions

  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (1)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |