1.0.0 • Published 5 years ago

@strong-roots-capital/zip v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

zip Build status npm version codecov

Stitch together two arrays by like-index

Why yet-another zip?

I needed a zip that

  • doesn't modify Array prototype
  • is strongly-typed
  • supports currying

Install

npm install @strong-roots-capital/zip

Use

import zip from '@strong-roots-capital/zip'

/* Basic use */
const a = [1, 2, 3]
const b = ['a', 'b', 'c']
console.log(zip(a, b))
//=>[ [ 1, 'a' ], [ 2, 'b' ], [ 3, 'c' ] ]

const zipWithA = zip(a.reverse())
console.log(zipWithA(b))
//=>[ [ 3, 'a' ], [ 2, 'b' ], [ 1, 'c' ] ]

Related