@kingjs/linq.intersect

Generates the set intersection of two sequences.

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/linq.intersect
1.0.83 years ago3 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:

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

  • Enumerable: See @kingjs/enumerable.define.

    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

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.