How to use the @esfx/equatable.Equaler.defaultEqualer function in @esfx/equatable

To help you get started, we’ve selected a few @esfx/equatable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esfx / esfx / packages / collections-hashset / src / __tests__ / hashSet.ts View on Github external
[Equatable.hash]() {
        return Equaler.defaultEqualer.hash(this.x)
             ^ Equaler.defaultEqualer.hash(this.y);
    }
}
github esfx / esfx / packages / collections-hashset / src / __tests__ / hashSet.ts View on Github external
[Equatable.hash]() {
        return Equaler.defaultEqualer.hash(this.x)
             ^ Equaler.defaultEqualer.hash(this.y);
    }
}
github rbuckton / iterable-query / src / lib / fn / startsWithAsync.ts View on Github external
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;
github rbuckton / iterable-query / src / lib / fn / corresponds.ts View on Github external
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);
}
github rbuckton / iterable-query / src / lib / fn / includes.ts View on Github external
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;
}
github rbuckton / iterable-query / src / lib / fn / startsWith.ts View on Github external
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;
github rbuckton / iterable-query / src / lib / fn / endsWithAsync.ts View on Github external
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;
github rbuckton / iterable-query / src / lib / fn / includesSequence.ts View on Github external
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;
github rbuckton / iterable-query / src / lib / fn / common.ts View on Github external
export function equate(x: T, y: T): boolean {
    return Equaler.defaultEqualer.equals(x, y);
}
github rbuckton / iterable-query / src / lib / fn / correspondsAsync.ts View on Github external
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);
}

@esfx/equatable

A low-level API for defining equality.

Apache-2.0
Latest version published 2 years ago

Package Health Score

42 / 100
Full package analysis

Similar packages