1.0.8 • Published 6 years ago

@kingjs/linq.intersect v1.0.8

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

@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

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

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