@kingjs/linq.sequence-equal

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

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
04Jun 21, 2021Jul 20, 2018Minified + gzip package size for @kingjs/linq.sequence-equal in KB

Readme

@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

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.