dstructs-to-array

Construct an array of arrays from a matrix.

Usage no npm install needed!

<script type="module">
  import dstructsToArray from 'https://cdn.skypack.dev/dstructs-to-array';
</script>

README

to-array

NPM version Build Status Coverage Status Dependencies

Construct an array of arrays from a Matrix.

Installation

$ npm install dstructs-to-array

For use in the browser, use browserify.

Usage

var toArray = require( 'dstructs-to-array' );

toArray( x )

Constructs an array of arrays. To convert a matrix,

var mat = matrix( [ 2, 2 ] );

var arr = toArray( mat )
// returns [ [ 0, 0 ], [ 0, 0 ] ]

If provided an empty matrix, the function returns an empty array.

var mat, arr;

mat = matrix( [0,0] );
arr = toArray( mat );
// returns []

mat = matrix( [0,10] );
arr = toArray( mat );
// returns []

mat = matrix( [10,0] );
arr = toArray( mat );
// returns []

Examples

var toArray = require( 'dstructs-to-array' ),
    matrix = require( 'dstructs-matrix' );

var data, mat;

data = new Int32Array( [ 1, 2, 3, 4 ] );
mat = matrix( data, [ 2, 2 ] );

console.log( toArray( mat ) );
// returns [ [ 1, 2 ], [ 3, 4 ] ]

To run the example code from the top-level application directory,

$ node ./examples/index.js

Tests

Unit

Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

License

MIT license.

Copyright

Copyright © 2015. The Compute.io Authors.