@kingjs/linq.intersect

1.0.8 • Public • Published

@kingjs/linq.intersect

Generates the set intersection of two sequences.

Usage

Intersect the numbers 0, 0, 1, 2 with the numbers 1, 0 like this:

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

var result = intersect.call(
  sequence(0, 0, 1, 2),
  sequence(1, 0)
)

toArray.call(result);

result:

[ 0, 1 ]

API

declare function intersect(
  this: Enumerable,
  second: Enumerable,
  idSelector?: (x) => any
)

Interfaces

Parameters

  • this: The first sequence.
  • second: The second sequence.
  • idSelector: Return a value whose stringified representation uniquely identifies an element.
    • x: The element to identify.

Return Value

A sequence of elements common to both sequences.

Remarks

Elements are deemed equal if their stringified id representations returned by idSelector are the same.

Only unique elements are included in the resulting sequence.

Elements are included in the order they appear in the first sequence.

Install

With npm installed, run

$ npm install @kingjs/linq.intersect

Acknowledgments

Like Enumerable.Intersect.

License

MIT

Analytics

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/linq.intersect

Weekly Downloads

1

Version

1.0.8

License

MIT

Unpacked Size

4.27 kB

Total Files

4

Last publish

Collaborators

  • kingces95