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 / src / freezableCollections.ts
Size: Mime:
// https://stackoverflow.com/questions/35747325/is-there-a-way-to-freeze-a-es6-map
const isFrozen = Object.isFrozen
var FreezableMap = (function(Map) {
  function FreezableMap() {
    Map.apply(this, arguments)
  }

  if (Map) FreezableMap.__proto__ = Map
  FreezableMap.prototype = Object.create(Map && Map.prototype)
  FreezableMap.prototype.constructor = FreezableMap

  FreezableMap.prototype.set = function set() {
    if (isFrozen(this)) return this
    return Map.prototype.set.apply(this, arguments)
  }
  FreezableMap.prototype.delete = function delete$1() {
    if (isFrozen(this)) return false
    return Map.prototype.delete.apply(this, arguments)
  }
  FreezableMap.prototype.clear = function clear() {
    if (isFrozen(this)) return false
    return Map.prototype.clear.call(this)
  }

  return FreezableMap
})(Map)

var FreezableSet = (function(Set) {
  function FreezableSet() {
    Set.apply(this, arguments)
  }

  if (Set) FreezableSet.__proto__ = Set
  FreezableSet.prototype = Object.create(Set && Set.prototype)
  FreezableSet.prototype.constructor = FreezableSet

  FreezableSet.prototype.add = function add() {
    if (isFrozen(this)) return this
    return Set.prototype.add.apply(this, arguments)
  }
  FreezableSet.prototype.delete = function delete$1() {
    if (isFrozen(this)) return false
    return Set.prototype.delete.apply(this, arguments)
  }
  FreezableSet.prototype.clear = function clear() {
    if (isFrozen(this)) return false
    return Set.prototype.clear.call(this)
  }

  return FreezableSet
})(Set)