1.0.10 • Published 6 years ago

@kingjs/linq.union v1.0.10

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

@kingjs/linq.union

Generates the set union of two sequences.

Usage

Create a union of the sequences

  • 0, 0, 1, 2, and
  • 1, 3, 3

like this:

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

var result = union.call(
  sequence(0, 0, 1, 2),
  sequence(1, 3, 3)
);

toArray.call(result);

result:

[0, 1, 2, 3]

Create a union of the same sequences as before but wrapped in an object like this:

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

var result = union.call(
  sequence({ id: 0 }, { id: 0 }, { id: 1 }, { id: 2 }),
  sequence({ id: 1 }, { id: 3 }, { id: 3 }),
  function(x) { return x.id; }
);

toArray.call(result);

result:

[{ id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }]

API

function union(
  this: Enumerable, 
  second: Enumerable, 
  idSelector?: (x) => any
): Enumerable;

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.

Result

A sequence containing unique elements of sequences first and second.

Remarks

Elements are deemed equal if their key's stringified representations are the same.

Elements are included in the order they are appear in the first sequence and then the second sequence.

Install

With npm installed, run

$ npm install @kingjs/link.union

Acknowledgments

Like Enumerable.Union.

License

MIT

Analytics

1.0.10

6 years ago

1.0.9

6 years ago

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