1.0.5 • Published 6 years ago

@kingjs/linq.zip v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@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

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago