Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) {
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,
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,
),
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;
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: {
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;
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),
},
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(
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}`);
}
}
shouldRefetch: (prevArgs, nextArgs) => !deepEqual(prevArgs, nextArgs),
};