1.0.9 • Published 7 years ago
@kingjs/linq.sequence-equal v1.0.9
@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
): booleanInterfaces
Enumerable: See @kingjs/enumerable.define.
Parameters
this: the first sequence being comparedtarget: the second sequence being comparedequal: 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-equalAcknowledgments
License
MIT