updated npm modules

This commit is contained in:
2019-05-20 20:43:45 -05:00
parent 2319197b81
commit f166b72b7d
1113 changed files with 8758 additions and 12227 deletions

34
node_modules/mem/index.js generated vendored
View File

@@ -5,13 +5,13 @@ const mapAgeCleaner = require('map-age-cleaner');
const cacheStore = new WeakMap();
const defaultCacheKey = (...args) => {
if (args.length === 0) {
const defaultCacheKey = (...arguments_) => {
if (arguments_.length === 0) {
return '__defaultKey';
}
if (args.length === 1) {
const [firstArgument] = args;
if (arguments_.length === 1) {
const [firstArgument] = arguments_;
if (
firstArgument === null ||
firstArgument === undefined ||
@@ -21,10 +21,10 @@ const defaultCacheKey = (...args) => {
}
}
return JSON.stringify(args);
return JSON.stringify(arguments_);
};
module.exports = (fn, options) => {
const mem = (fn, options) => {
options = Object.assign({
cacheKey: defaultCacheKey,
cache: new Map(),
@@ -45,25 +45,23 @@ module.exports = (fn, options) => {
});
};
const memoized = function (...args) {
const key = options.cacheKey(...args);
const memoized = function (...arguments_) {
const key = options.cacheKey(...arguments_);
if (cache.has(key)) {
const c = cache.get(key);
return c.data;
return cache.get(key).data;
}
const ret = fn.call(this, ...args);
const cacheItem = fn.call(this, ...arguments_);
setData(key, ret);
setData(key, cacheItem);
if (isPromise(ret) && options.cachePromiseRejection === false) {
if (isPromise(cacheItem) && options.cachePromiseRejection === false) {
// Remove rejected promises from cache unless `cachePromiseRejection` is set to `true`
ret.catch(() => cache.delete(key));
cacheItem.catch(() => cache.delete(key));
}
return ret;
return cacheItem;
};
try {
@@ -77,6 +75,10 @@ module.exports = (fn, options) => {
return memoized;
};
module.exports = mem;
// TODO: Remove this for the next major release
module.exports.default = mem;
module.exports.clear = fn => {
const cache = cacheStore.get(fn);