map-tuple

v1.0.0
Map a list of n-tuples to a function with n separate arguments
map tuple functional

map-tuple

Map a list of n-tuples to a function with n separate arguments

Usage

var mapTuple = require('map-tuple');

var tuples = [
  [1],
  [2, 3],
  ['x', 'y', 'z'],
];

var result = mapTuple(tuples, function(a, b, c) {
  console.log(a, b, c);
  return a + (b || 0) + (c || 0);
});
//=> 1 undefined undefined 
//=> 2 3 undefined
//=> x y z 

console.log(result);
//=> [1, 5, "xyz"]
npm i map-tuple

Metadata

  • Unknown
  • >=0.10
  • Andres Suarez
  • released 10/25/2014

Downloads

Maintainers