Socket
Socket
Sign inDemoInstall

@iterables/zip

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @iterables/zip

combine iterables into a list of tuples


Version published
Weekly downloads
875
increased by95.31%
Maintainers
1
Install size
43.8 kB
Created
Weekly downloads
 

Changelog

Source

1.0.2 (2017-04-08)

<a name="1.0.1"></a>

Readme

Source

@iterables/zip

Combine iterables into a list of tuples, where the Nth tuple is comprised of the Nth element from each iterable.

const zip = require('@iterables/zip')

const iter = zip('abc', [1, 2, 3], 'xyz')

console.log(Array.from(iter)) // [['a', 1, 'x'], ['b', 2, 'y'], ['c', 3, 'z']]

const map = new Map()
map.set('a', 3)
map.set('b', 0)

console.log(...zip(...map)) // ['a', 'b'] [3, 0]
console.log(...zip.longest(9999)([1,2], [1,2,3])) // [1, 1] [2, 2] [9999, 3]

Installation

$ npm install --save @iterables/zip

API

zip(...iterables) -> Iterator<Array<T>>

  • iterables: any Iterator — a generator instance, Array, Map, String, or Set

Returns a zipped iterator. If iterables are of different lengths, the resulting iterator will be the same length as the shortest iterable.

zip.longest(fill) -> Generator

  • fill: a value to fill

Returns a zipped iterator. If iterables are of different lengths, the resulting iterator will be the same length as the longest iterable. Missing values from the shorter iterables will be replaced with fill.

License

MIT

FAQs

Last updated on 08 Apr 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc