1.0.10 • Published 7 years ago

@kingjs/linq.distinct v1.0.10

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

@kingjs/linq.distinct

Generates a sequence composed of the distinct elements of another sequence.

Usage

Remove duplicates from the sequence 0, 0 like this:

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

var justZero = distinct.call(sequence(0, 0));

toArray.call(justZero);

result:

[0]

Remove duplicates from a sequence based on an id like this:

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

var enumerable = sequence(
  { id: 0, name: 'foo' },
  { id: 0, name: 'bar' }
);

var justZero = distinct.call(
  enumerable, 
  function(x) { return x.id; }
);

toArray.call(justZero);

result:

[{ 
  id: 0,
  name: 'foo'
}]

API

function distinct(
  this: Enumerable, 
  selectId?: (x) => any
): Enumerable;

Interfaces

Parameters

  • this: The sequence to deduplicate.
  • selectId: Optional, function to select an identifier.

Result

Returns a de-duplicated sequence.

Install

With npm installed, run

$ npm install @kingjs/link.distinct

Acknowledgments

Like Enumerable.Distinct.

License

MIT

Analytics

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago