combine-arrays
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "combine-arrays", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "For people who hate for loops and want to iterate over multiple arrays with a single function", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,21 +8,39 @@ | ||
var combine = require('combine-arrays') | ||
```js | ||
var combine = require('combine-arrays') | ||
var ary1 = ['what', 'what', 'in', 'the', 'butt'] | ||
var ary2 = ['ho', 'hi', 'hup', 'hurr', 'HAH', '...huh?'] | ||
var ary1 = ['what', 'what', 'in', 'the', 'butt'] | ||
var ary2 = ['ho', 'hi', 'hup', 'hurr', 'HAH', '...huh?'] | ||
var output = combine({ | ||
first: ary1, | ||
second: ary2 | ||
}) | ||
var output = combine({ | ||
first: ary1, | ||
second: ary2 | ||
}) | ||
console.log(output) | ||
// [ { first: 'what', second: 'ho' }, | ||
// { first: 'what', second: 'hi' }, | ||
// { first: 'in', second: 'hup' }, | ||
// { first: 'the', second: 'hurr' }, | ||
// { first: 'butt', second: 'HAH' }, | ||
// { first: undefined, second: '...huh?' } ] | ||
console.log(output) | ||
// [ { first: 'what', second: 'ho' }, | ||
// { first: 'what', second: 'hi' }, | ||
// { first: 'in', second: 'hup' }, | ||
// { first: 'the', second: 'hurr' }, | ||
// { first: 'butt', second: 'HAH' }, | ||
// { first: undefined, second: '...huh?' } ] | ||
``` | ||
```js | ||
var combine = require('combine-arrays') | ||
var output = combine([ | ||
['a', 'ax', 'app', 'ache', 'anger'], | ||
['b', 'be', 'bin'], | ||
['c', 'ci', 'cat', 'cool', 'chant'] | ||
]) | ||
console.log(output) | ||
// [ { 0: 'a', 1: 'b', 2: 'c' }, | ||
// { 0: 'ax', 1: 'be', 2: 'ci' }, | ||
// { 0: 'app', 1: 'bin', 2: 'cat' }, | ||
// { 0: 'ache', 1: undefined, 2: 'cool' }, | ||
// { 0: 'anger', 1: undefined, 2: 'chant' } ] | ||
``` | ||
License | ||
@@ -29,0 +47,0 @@ ====== |
33
test.js
@@ -14,7 +14,7 @@ var test = require('tape') | ||
t.deepEqual(output, [ { first: 'what', second: 'ho' }, | ||
{ first: 'what', second: 'hi' }, | ||
{ first: 'in', second: 'hup' }, | ||
{ first: 'the', second: 'hurr' }, | ||
{ first: 'butt', second: 'HAH' }, | ||
{ first: undefined, second: '...huh?' } ]) | ||
{ first: 'what', second: 'hi' }, | ||
{ first: 'in', second: 'hup' }, | ||
{ first: 'the', second: 'hurr' }, | ||
{ first: 'butt', second: 'HAH' }, | ||
{ first: undefined, second: '...huh?' } ]) | ||
@@ -63,1 +63,24 @@ t.end() | ||
}) | ||
test('array example from the readme', function(t) { | ||
var output = combine([ | ||
['a', 'ax', 'app', 'ache', 'anger'], | ||
['b', 'be', 'bin'], | ||
['c', 'ci', 'cat', 'cool', 'chant'] | ||
]) | ||
var expectedOutput = [ | ||
[ 'a', 'b', 'c' ], | ||
[ 'ax', 'be', 'ci' ], | ||
[ 'app', 'bin', 'cat' ], | ||
[ 'ache', undefined, 'cool' ], | ||
[ 'anger', undefined, 'chant'] | ||
] | ||
t.deepEqual(output, expectedOutput) | ||
t.ok(Array.isArray(output), 'Output is an array') | ||
t.equal(output.length, expectedOutput.length) | ||
t.end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3950
5
92
49