@kingjs/linq.sequence-equal

1.0.9 • Public • Published

@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

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/linq.sequence-equal

Weekly Downloads

0

Version

1.0.9

License

MIT

Unpacked Size

4.01 kB

Total Files

4

Last publish

Collaborators

  • kingces95