UNPKG

vanillajs-browser-helpers

Version:

Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS in the browser

22 lines (21 loc) 634 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resetCache = void 0; let _cache = new WeakMap(); const resetCache = () => { _cache = new WeakMap(); }; exports.resetCache = resetCache; function elmData(elm, key, data) { let elmCache = _cache.get(elm); if (!key) { return elmCache; } if (data !== undefined) { if (!elmCache) { elmCache = {}; _cache.set(elm, elmCache); } elmCache[key] = data; } return elmCache === null || elmCache === void 0 ? void 0 : elmCache[key]; } exports.default = elmData;