How to use the fast-equals.deepEqual function in fast-equals

To help you get started, we’ve selected a few fast-equals 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 DestinyItemManager / DIM / src / app / storage / sync.service.ts View on Github external
async set(value: Partial, PUT = false): Promise {
    if (!cached) {
      throw new Error('Must call get at least once before setting');
    }

    if (!PUT && deepEqual(_.pick(cached, Object.keys(value)), value)) {
      if ($featureFlags.debugSync) {
        console.log(_.pick(cached, Object.keys(value)), value);
        console.log('Skip save, already got it');
      }
      return;
    }

    // use replace to override the data. normally we're doing a PATCH
    if (PUT) {
      // update our data
      cached = copy(value) as DimData;
    } else {
      Object.assign(cached, copy(value));
    }

    for (const adapter of adapters) {
github planttheidea / inline-loops.macro / __tests__ / __runtime__ / map.js View on Github external
return isEven;
        }),
        DECREMENTING_ARRAY_RESULT,
      ),
    },
    object: {
      false: isEqual(
        mapObject(Object.assign({}, OBJECT), value => {
          const isEven = value % 2 === 0;

          return isEven;
        }),
        BAD_OBJECT_RESULT,
      ),
      true: isEqual(
        mapObject(Object.assign({}, OBJECT), value => {
          const isEven = value % 2 === 0;

          return isEven;
        }),
        OBJECT_RESULT,
      ),
    },
    standard: {
      false: isEqual(
        map([].concat(ARRAY), value => {
          const isEven = value % 2 === 0;

          return isEven;
        }),
        BAD_ARRAY_RESULT,
github planttheidea / inline-loops.macro / __tests__ / __runtime__ / reduce.js View on Github external
object: {
      false: isEqual(
        reduceObject(OBJECT, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        BAD_OBJECT_RESULT,
      ),
      true: isEqual(
        reduceObject(OBJECT, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        OBJECT_RESULT,
      ),
    },
    standard: {
      false: isEqual(
        reduce(ARRAY, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        BAD_ARRAY_RESULT,
      ),
      true: isEqual(
        reduce(ARRAY, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        ARRAY_RESULT,
      ),
    },
  },
  inlinedArrowReturn: {
    decrementing: {
      false: isEqual(
        reduceRight(
          ARRAY,
          (total, value) => {
            return value % 2 === 0 ? total + value : total;
          },
          10,
        ),
        BAD_DECREMENTING_ARRAY_RESULT,
github planttheidea / inline-loops.macro / __tests__ / __runtime__ / reduce-no-initialValue.js View on Github external
),
      true: isEqual(
        reduceRight(ARRAY, function(total, value) {
          return value % 2 === 0 ? total + value : total;
        }),
        DECREMENTING_ARRAY_RESULT,
      ),
    },
    object: {
      false: isEqual(
        reduceObject(OBJECT, function(total, value) {
          return value % 2 === 0 ? total + value : total;
        }),
        BAD_OBJECT_RESULT,
      ),
      true: isEqual(
        reduceObject(OBJECT, function(total, value) {
          return value % 2 === 0 ? total + value : total;
        }),
        OBJECT_RESULT,
      ),
    },
    standard: {
      false: isEqual(
        reduce(ARRAY, (total, value) => {
          return value % 2 === 0 ? total + value : total;
        }),
        BAD_ARRAY_RESULT,
      ),
      true: isEqual(
        reduce(ARRAY, (total, value) => {
          return value % 2 === 0 ? total + value : total;
github planttheidea / inline-loops.macro / __tests__ / __runtime__ / reduce.js View on Github external
decrementing: {
      false: isEqual(
        reduceRight(ARRAY, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        BAD_DECREMENTING_ARRAY_RESULT,
      ),
      true: isEqual(
        reduceRight(ARRAY, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        DECREMENTING_ARRAY_RESULT,
      ),
    },
    object: {
      false: isEqual(
        reduceObject(OBJECT, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        BAD_OBJECT_RESULT,
      ),
      true: isEqual(
        reduceObject(OBJECT, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        OBJECT_RESULT,
      ),
    },
    standard: {
      false: isEqual(
        reduce(ARRAY, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        BAD_ARRAY_RESULT,
      ),
      true: isEqual(
        reduce(ARRAY, (total, value) => (value % 2 === 0 ? total + value : total), 10),
        ARRAY_RESULT,
      ),
    },
  },
  inlinedArrowReturn: {
github planttheidea / inline-loops.macro / __tests__ / __runtime__ / filter.js View on Github external
decrementing: {
      false: isEqual(filterRight(ARRAY, isEven), BAD_DECREMENTING_ARRAY_RESULT),
      true: isEqual(filterRight(ARRAY, isEven), DECREMENTING_ARRAY_RESULT),
    },
    object: {
      false: isEqual(filterObject(OBJECT, isEven), BAD_OBJECT_RESULT),
      true: isEqual(filterObject(OBJECT, isEven), OBJECT_RESULT),
    },
    standard: {
      false: isEqual(filter(ARRAY, isEven), BAD_ARRAY_RESULT),
      true: isEqual(filter(ARRAY, isEven), ARRAY_RESULT),
    },
  },
  inlinedArrowExpression: {
    decrementing: {
      false: isEqual(filterRight(ARRAY, value => value % 2 === 0), BAD_DECREMENTING_ARRAY_RESULT),
      true: isEqual(filterRight(ARRAY, value => value % 2 === 0), DECREMENTING_ARRAY_RESULT),
    },
    object: {
      false: isEqual(filterObject(OBJECT, value => value % 2 === 0), BAD_OBJECT_RESULT),
      true: isEqual(filterObject(OBJECT, value => value % 2 === 0), OBJECT_RESULT),
    },
    standard: {
      false: isEqual(filter(ARRAY, value => value % 2 === 0), BAD_ARRAY_RESULT),
      true: isEqual(filter(ARRAY, value => value % 2 === 0), ARRAY_RESULT),
    },
  },
  inlinedArrowReturn: {
    decrementing: {
      false: isEqual(
        filterRight(ARRAY, value => {
          return value % 2 === 0;
github planttheidea / inline-loops.macro / __tests__ / __runtime__ / map.js View on Github external
const ARRAY_RESULT = ARRAY.map(isEven);

const BAD_DECREMENTING_ARRAY_RESULT = [...BAD_ARRAY_RESULT].reverse();
const DECREMENTING_ARRAY_RESULT = [...ARRAY_RESULT].reverse();

const BAD_OBJECT_RESULT = Object.assign({}, OBJECT);
const OBJECT_RESULT = Object.keys(OBJECT).reduce((evenObject, key) => {
  evenObject[key] = isEven(OBJECT[key]);

  return evenObject;
}, {});

module.exports = {
  cached: {
    decrementing: {
      false: isEqual(mapRight(ARRAY, isEven), BAD_DECREMENTING_ARRAY_RESULT),
      true: isEqual(mapRight(ARRAY, isEven), DECREMENTING_ARRAY_RESULT),
    },
    object: {
      false: isEqual(mapObject(OBJECT, isEven), BAD_OBJECT_RESULT),
      true: isEqual(mapObject(OBJECT, isEven), OBJECT_RESULT),
    },
    standard: {
      false: isEqual(map(ARRAY, isEven), BAD_ARRAY_RESULT),
      true: isEqual(map(ARRAY, isEven), ARRAY_RESULT),
    },
  },
  inlinedArrowExpression: {
    decrementing: {
      false: isEqual(mapRight(ARRAY, value => value % 2 === 0), BAD_DECREMENTING_ARRAY_RESULT),
      true: isEqual(mapRight(ARRAY, value => value % 2 === 0), DECREMENTING_ARRAY_RESULT),
    },
github planttheidea / inline-loops.macro / __tests__ / __runtime__ / reduce-no-initialValue.js View on Github external
object: {
      false: isEqual(
        reduceObject(OBJECT, (total, value) => {
          return value % 2 === 0 ? total + value : total;
        }),
        BAD_OBJECT_RESULT,
      ),
      true: isEqual(
        reduceObject(OBJECT, (total, value) => {
          return value % 2 === 0 ? total + value : total;
        }),
        OBJECT_RESULT,
      ),
    },
    standard: {
      false: isEqual(
        reduce(ARRAY, (total, value) => {
          return value % 2 === 0 ? total + value : total;
        }),
        BAD_ARRAY_RESULT,
      ),
      true: isEqual(
        reduce(ARRAY, (total, value) => {
          return value % 2 === 0 ? total + value : total;
        }),
        ARRAY_RESULT,
      ),
    },
  },
  inlinedFunctionReturn: {
    decrementing: {
      false: isEqual(
github DestinyItemManager / DIM / src / app / manifest / manifest-service-json.ts View on Github external
private async loadManifestFromCache(version: string, tableWhitelist: string[]): Promise {
    if (alwaysLoadRemote) {
      throw new Error('Testing - always load remote');
    }

    this.statusText = `${t('Manifest.Load')}...`;
    const currentManifestVersion = localStorage.getItem(this.localStorageKey);
    const currentWhitelist = JSON.parse(
      localStorage.getItem(this.localStorageKey + '-whitelist') || '[]'
    );
    if (currentManifestVersion === version && deepEqual(currentWhitelist, tableWhitelist)) {
      const manifest = await get(this.idbKey);
      if (!manifest) {
        throw new Error('Empty cached manifest file');
      }
      return manifest;
    } else {
      throw new Error(`version mismatch: ${version} ${currentManifestVersion}`);
    }
  }

fast-equals

A blazing fast equality comparison, either shallow or deep

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis