0.0.1 • Published 8 years ago

interleavejs v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

interleavejs Build Status

Clojure's interleave function in JavaScript

The interleave function takes multiple arrays and produces a new array that interleaves values from each array until one of the array is exhausted.

Install

$ npm install --save interleavejs

Usage

const interleave = require('interleavejs')

interleave([1, 2, 3], ['a', 'b', 'c', 'd']) // [1, 'a', 2, 'b', 3, 'c']

// more arrays
interleave([1, 2, 3], [4, 5, 6], [7, 8, 9]) // [1, 4, 7, 2, 5, 8, 3, 6, 9]

// array-like object
interleave([1, 2, 3], 'abc') // [1, 'a', 2, 'b', 3, 'c']

// return `[]` if there is only one array
interleaves([1, 2]) // []

API

interleavejs(arr1, arr2, ..., arrN)

arrN

Type: array or array-like object

License

MIT © JIANG Di