@kingjs/linq.zip

1.0.5 • Public • Published

@kingjs/linq.zip

Generates a sequence of elements composed of elements of two sequences which share the same index.

Usage

Zip the numbers 0, 1, 2 with the letters a, b like this:

var zip = require('@kingjs/linq.zip');
var sequence = require('@kingjs/enumerable.create');
var toArray = require('@kingjs/linq.to-array');

var result = zip.call(
  sequence(0, 1, 2),
  sequence(`a`, `b`),
  function(n, l) { 
    return { number: n, letter: l }; 
  }
)

toArray.call(result);

result:

[
  { number: 0, letter: 'a' },
  { number: 1, letter: 'b' }
]

API

declare function zip(
  this: Enumerable,
  second: Enumerable,
  resultSelector: (firstElement, secondElement) => any
): Enumerable

Interfaces

Parameters

  • this: The first sequence.
  • second: The second sequence.
  • resultSelector: Joins elements of the first and second sequence which share the same index.
    • firstElement: Element of the first sequence.
    • secondElement: Element of the second sequence.

Return Value

A sequence of elements of first sequence joined with elements of the second sequence.

Remarks

Elements without a partner are ignored.

Install

With npm installed, run

$ npm install @kingjs/linq.zip

Acknowledgments

Like Enumerable.Zip.

License

MIT

Analytics

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/linq.zip

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

3.73 kB

Total Files

4

Last publish

Collaborators

  • kingces95