{"version":3,"sources":["webpack:///../node_modules/map-age-cleaner/dist/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAa;AACb;AACA;AACA,mCAAmC,MAAM,6BAA6B,EAAE,YAAY,WAAW,EAAE;AACjG,kCAAkC,MAAM,iCAAiC,EAAE,YAAY,WAAW,EAAE;AACpG,+BAA+B,iEAAiE,uBAAuB,EAAE,4BAA4B;AACrJ;AACA,KAAK;AACL;AACA;AACA,4CAA4C;AAC5C;AACA,8CAA8C,cAAc;AAC5D,kCAAkC,mBAAO,CAAC,iDAAS;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA","file":"vendor.map-age-cleaner.d0b194bb1fb70bfb7644.js","sourcesContent":["\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst p_defer_1 = __importDefault(require(\"p-defer\"));\nfunction mapAgeCleaner(map, property = 'maxAge') {\n let processingKey;\n let processingTimer;\n let processingDeferred;\n const cleanup = () => __awaiter(this, void 0, void 0, function* () {\n if (processingKey !== undefined) {\n // If we are already processing an item, we can safely exit\n return;\n }\n const setupTimer = (item) => __awaiter(this, void 0, void 0, function* () {\n processingDeferred = p_defer_1.default();\n const delay = item[1][property] - Date.now();\n if (delay <= 0) {\n // Remove the item immediately if the delay is equal to or below 0\n map.delete(item[0]);\n processingDeferred.resolve();\n return;\n }\n // Keep track of the current processed key\n processingKey = item[0];\n processingTimer = setTimeout(() => {\n // Remove the item when the timeout fires\n map.delete(item[0]);\n if (processingDeferred) {\n processingDeferred.resolve();\n }\n }, delay);\n // tslint:disable-next-line:strict-type-predicates\n if (typeof processingTimer.unref === 'function') {\n // Don't hold up the process from exiting\n processingTimer.unref();\n }\n return processingDeferred.promise;\n });\n try {\n for (const entry of map) {\n yield setupTimer(entry);\n }\n }\n catch (_a) {\n // Do nothing if an error occurs, this means the timer was cleaned up and we should stop processing\n }\n processingKey = undefined;\n });\n const reset = () => {\n processingKey = undefined;\n if (processingTimer !== undefined) {\n clearTimeout(processingTimer);\n processingTimer = undefined;\n }\n if (processingDeferred !== undefined) { // tslint:disable-line:early-exit\n processingDeferred.reject(undefined);\n processingDeferred = undefined;\n }\n };\n const originalSet = map.set.bind(map);\n map.set = (key, value) => {\n if (map.has(key)) {\n // If the key already exist, remove it so we can add it back at the end of the map.\n map.delete(key);\n }\n // Call the original `map.set`\n const result = originalSet(key, value);\n // If we are already processing a key and the key added is the current processed key, stop processing it\n if (processingKey && processingKey === key) {\n reset();\n }\n // Always run the cleanup method in case it wasn't started yet\n cleanup(); // tslint:disable-line:no-floating-promises\n return result;\n };\n cleanup(); // tslint:disable-line:no-floating-promises\n return map;\n}\nexports.default = mapAgeCleaner;\n// Add support for CJS\nmodule.exports = mapAgeCleaner;\nmodule.exports.default = mapAgeCleaner;\n"],"sourceRoot":""}