Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[Equatable.hash]() {
return Equaler.defaultEqualer.hash(this.x)
^ Equaler.defaultEqualer.hash(this.y);
}
}
[Equatable.hash]() {
return Equaler.defaultEqualer.hash(this.x)
^ Equaler.defaultEqualer.hash(this.y);
}
}
export async function startsWithAsync(left: AsyncQueryable, right: AsyncQueryable, equaler: EqualityComparison | Equaler = Equaler.defaultEqualer): Promise {
if (typeof equaler === "function") equaler = Equaler.create(equaler);
assert.mustBeAsyncQueryable(left, "left");
assert.mustBeAsyncQueryable(right, "right");
assert.mustBeEqualer(equaler, "equaler");
const leftIterator = GetAsyncIterator(ToPossiblyAsyncIterable(left));
let leftDone = false;
let leftValue: T;
try {
const rightIterator = GetAsyncIterator(ToPossiblyAsyncIterable(right));
let rightDone = false;
let rightValue: T;
try {
for (;;) {
({ done: leftDone, value: leftValue } = await leftIterator.next());
({ done: rightDone, value: rightValue } = await rightIterator.next());
if (rightDone) return true;
export function corresponds(left: Queryable, right: Queryable, equaler: EqualityComparison | Equaler = Equaler.defaultEqualer): boolean {
assert.mustBeQueryable(left, "left");
assert.mustBeQueryable(right, "right");
assert.mustBeObject(equaler, "equaler");
return correspondsBy(left, right, identity, identity, equaler);
}
export function includes(source: Queryable, value: T, equaler: EqualityComparison | Equaler = Equaler.defaultEqualer): boolean {
if (typeof equaler === "function") equaler = Equaler.create(equaler);
assert.mustBeQueryable(source, "source");
assert.mustBeEqualer(equaler, "equaler");
for (const element of ToIterable(source)) {
if (equaler.equals(value, element)) {
return true;
}
}
return false;
}
export function startsWith(left: Queryable, right: Queryable, equaler: EqualityComparison | Equaler = Equaler.defaultEqualer): boolean {
if (typeof equaler === "function") equaler = Equaler.create(equaler);
assert.mustBeQueryable(left, "left");
assert.mustBeQueryable(right, "right");
assert.mustBeEqualer(equaler, "equaler");
const leftIterator = GetIterator(ToIterable(left));
let leftDone = false;
let leftValue: T;
try {
const rightIterator = GetIterator(ToIterable(right));
let rightDone = false;
let rightValue: T;
try {
for (;;) {
({ done: leftDone, value: leftValue } = leftIterator.next());
({ done: rightDone, value: rightValue } = rightIterator.next());
if (rightDone) return true;
export async function endsWithAsync(left: AsyncQueryable, right: AsyncQueryable, equaler: EqualityComparison | Equaler = Equaler.defaultEqualer): Promise {
if (typeof equaler === "function") equaler = Equaler.create(equaler);
assert.mustBeAsyncQueryable(left, "left");
assert.mustBeAsyncQueryable(right, "right");
assert.mustBeEqualer(equaler, "equaler");
const rightArray = await toArrayAsync(right);
const numElements = rightArray.length;
if (numElements <= 0) {
return true;
}
const leftArray = await toArrayAsync(takeRightAsync(left, numElements));
if (leftArray.length < numElements) {
return false;
}
for (let i = 0; i < numElements; i++) {
if (!equaler.equals(leftArray[i], rightArray[i])) {
return false;
export function includesSequence(left: Queryable, right: Queryable, equaler: EqualityComparison | Equaler = Equaler.defaultEqualer): boolean {
if (typeof equaler === "function") equaler = Equaler.create(equaler);
assert.mustBeQueryable(left, "source");
assert.mustBeQueryable(right, "other");
assert.mustBeEqualer(equaler, "equaler");
const rightArray = toArray(right);
const numRightElements = rightArray.length;
if (numRightElements <= 0) {
return true;
}
const span: T[] = [];
for (const leftValue of ToIterable(left)) {
for (;;) {
const rightValue = rightArray[span.length];
if (equaler.equals(leftValue, rightValue)) {
if (span.length + 1 >= numRightElements) {
return true;
export function equate(x: T, y: T): boolean {
return Equaler.defaultEqualer.equals(x, y);
}
export async function correspondsAsync(left: AsyncQueryable, right: AsyncQueryable, equaler: EqualityComparison | Equaler = Equaler.defaultEqualer): Promise {
assert.mustBeAsyncQueryable(left, "left");
assert.mustBeAsyncQueryable(right, "right");
assert.mustBeObject(equaler, "equality");
return await correspondsByAsync(left, right, identity, identity, equaler);
}