UNPKG

lr-core

Version:
38 lines (28 loc) 812 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _assignPrototype = require('./assignPrototype.js'); var _assignPrototype2 = _interopRequireDefault(_assignPrototype); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } class SubclassableMap { constructor(...args) { this.__map__ = new Map(...args); } get size() { return this.__map__.size; } } (0, _assignPrototype2.default)(Map, SubclassableMap, '__map__'); const MAP_SUBCLASSABLE = (() => { var key = {}; class M extends Map {} try { var map = new M(); map.set(key, 123); } catch (e) { return false; } return map instanceof M && map.has(key) && map.get(key) === 123; })(); exports.default = MAP_SUBCLASSABLE ? Map : SubclassableMap;