Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
chain-able-lego / dist / freezableCollections.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * @see https://stackoverflow.com/questions/35747325/is-there-a-way-to-freeze-a-es6-map
 */
const isFrozen = Object.isFrozen;
const FreezableMap = (Map => {
    class FreezableMap {
        constructor() {
            Map.apply(this, arguments);
        }
        set() {
            if (isFrozen(this))
                return this;
            return Map.prototype.set.apply(this, arguments);
        }
        delete() {
            if (isFrozen(this))
                return false;
            return Map.prototype.delete.apply(this, arguments);
        }
        clear() {
            if (isFrozen(this))
                return false;
            return Map.prototype.clear.call(this);
        }
    }
    if (Map)
        FreezableMap.__proto__ = Map;
    FreezableMap.prototype = Object.create(Map && Map.prototype);
    FreezableMap.prototype.constructor = FreezableMap;
    return FreezableMap;
})(Map);
exports.FreezableMap = FreezableMap;
const FreezableSet = (Set => {
    class FreezableSet {
        constructor() {
            Set.apply(this, arguments);
        }
        add() {
            if (isFrozen(this))
                return this;
            return Set.prototype.add.apply(this, arguments);
        }
        delete() {
            if (isFrozen(this))
                return false;
            return Set.prototype.delete.apply(this, arguments);
        }
        clear() {
            if (isFrozen(this))
                return false;
            return Set.prototype.clear.call(this);
        }
    }
    if (Set)
        FreezableSet.__proto__ = Set;
    FreezableSet.prototype = Object.create(Set && Set.prototype);
    FreezableSet.prototype.constructor = FreezableSet;
    return FreezableSet;
})(Set);
exports.FreezableSet = FreezableSet;
//# sourceMappingURL=freezableCollections.js.map