array-interweave

Produce a new array from two source arrays with alternating values from each source array

Usage no npm install needed!

<script type="module">
  import arrayInterweave from 'https://cdn.skypack.dev/array-interweave';
</script>

README

array-interweave

js-standard-style Build Status Code Climate codecov.io Dependency Status devDependency Status

NPM

Produce a new array from two source arrays with alternating values from each source array.

Installation

$ npm install array-interweave --save

Usage

const interweave = require('array-interweave')
const sourceA = [1, 2, 3, 4, 5]
const sourceB = ['A', 'B', 'C']
const mergedResult = interweave(sourceA, sourceB)
// => [1, 'A', 2, 'B', 3, 'C', 4, 5]
const interweave = require('array-interweave')
const sourceA = [0x55, {foo: 'bar'}, 'apples']
const sourceB = [1, 2, 3, 4, 5]
const mergedResult = interweave(sourceA, sourceB)
// => [0x55, 1, {foo: 'bar'}, 2, 'apples', 3, 4, 5]

Tests

iUnit tests use Mocha, Unit.js, and Istanbul

$ npm run test
$ npm run test-html-cov # Will open HTML coverage report in Google Chrome on OSX

License

MIT