JSPM

compute-unzip

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 109
  • Score
    100M100P100Q88528F

Unzips a zipped array (i.e., a nested array of tuples).

Package Exports

  • compute-unzip

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (compute-unzip) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Unzip

NPM version Build Status Coverage Status Dependencies

Unzips a zipped array (i.e., a nested array of tuples).

Installation

$ npm install compute-unzip

For use in the browser, use browserify.

Usage

var unzip = require( 'compute-unzip' );

unzip( arr[, idx] )

Unzips a zipped array (i.e., a nested array of tuples).

var arr = [ [1,'a',3], [2,'b',4] ];

var out = unzip( arr );
// returns [ [1,2], ['a','b'], [3,4] ];

To unzip specific tuple elements, you can provide an array of indices as an optional second argument.

var arr = [ [1,'a',3], [2,'b',4] ];

var out = unzip( arr, [0,2] );
// returns [ [1,2], [3,4] ];

Examples

var unzip = require( 'compute-unzip' ),
    mean = require( 'compute-mean' );

// Simulate some data...
var arr = new Array( 100 ),
    len = 5;

for ( var i = 0; i < arr.length; i++ ) {
    arr[ i ] = new Array( len );
    for ( var j = 0; j < len; j++ ) {
        arr[ i ][ j ] = Math.round( Math.random()*Math.pow(10,j) );
    }
}
// Unzip and compute the means...
var out = unzip( arr );

var mu = new Array( len );
for ( var k = 0; k < len; k++ ) {
    mu[ k ] = mean( out[k] );
}
console.log( mu.join( '\t' ) );

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

$ node ./examples/index.js

Notes

This function is complementary to compute-zip and is inspired by Python's zip function.

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 © 2014-2015. Athan Reines.