1.0.9 • Published 6 years ago

@kingjs/linq.sequence-equal v1.0.9

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

@kingjs/linq.sequence-equal

Returns true if two sequences contain the same number of elements and those that share the same index are equal.

Usage

Test if [1,2,3] is equal to other arrays like this:

var sequenceEqual = require('@kingjs/linq.sequence-equal');
var sequence = require('@kingjs/enumerable.create');

var expected = sequence(1, 2, 3);

var toFew = sequence(1, 2);
var tooMany = sequence(1, 2, 3, 4);
var wrongOrder = sequence(3, 2, 1);
var justRight = sequence(1, 2, 3);

var result = {
  tooFew: sequenceEqual.call(expected, toFew),
  tooMany: sequenceEqual.call(expected, tooMany),
  wrongOrder: sequenceEqual.call(expected, wrongOrder),
  justRight: sequenceEqual.call(expected, justRight),
};

returns:

{
  tooFew: false,
  tooMany: false,
  wrongOrder: false,
  justRight: true
}

API

declare function sequenceEqual(
    this: Enumerable,
    target: Enumerable,
    equal?: (left, right) => boolean
): boolean

Interfaces

Parameters

  • this: the first sequence being compared
  • target: the second sequence being compared
  • equal: optional equality predicate.

Return Value

true if both sequences have the same number of elements and corresponding elements compare ==, otherwise false.

Remarks

The default value for equal is exposed by @kingjs/linq.

Install

With npm installed, run

$ npm install @kingjs/linq.sequence-equal

Acknowledgments

Like Enumerable.SequenceEqual

License

MIT

Analytics

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