Travis build: 1358 [cron]
This commit is contained in:
11
test/zipWith/zipWith.js
Normal file
11
test/zipWith/zipWith.js
Normal file
@ -0,0 +1,11 @@
|
||||
const zipWith = (...arrays) => {
|
||||
const length = arrays.length;
|
||||
let fn = length > 1 ? arrays[length - 1] : undefined;
|
||||
fn = typeof fn == 'function' ? (arrays.pop(), fn) : undefined;
|
||||
const maxLength = Math.max(...arrays.map(x => x.length));
|
||||
const result = Array.from({ length: maxLength }).map((_, i) => {
|
||||
return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);
|
||||
});
|
||||
return fn ? result.map(arr => fn(...arr)) : result;
|
||||
};
|
||||
module.exports = zipWith
|
||||
13
test/zipWith/zipWith.test.js
Normal file
13
test/zipWith/zipWith.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const zipWith = require('./zipWith.js');
|
||||
|
||||
test('Testing zipWith', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof zipWith === 'function', 'zipWith is a Function');
|
||||
//t.deepEqual(zipWith(args..), 'Expected');
|
||||
//t.equal(zipWith(args..), 'Expected');
|
||||
//t.false(zipWith(args..), 'Expected');
|
||||
//t.throws(zipWith(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user