@kingjs/linq.intersect

Generates the set intersection of two sequences.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/linq.intersect
091.0.84 years ago4 years agoMinified + gzip package size for @kingjs/linq.intersect in KB

Readme

@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: ```js 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: ```js 0, 1 ```

API

```ts 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.aspx).

License

MIT Analytics