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    
@skava/modules / ___dist / state-tree / UniqueDictionary.tsx
Size: Mime:
import { fromMapToObj } from 'exotic'
import { random } from './deps/random'


// @class
// eslint-disable-next-line
var UniqueDictionary = (function (Map) {
  let Mappy = (UniqueDictionary = Map)

  let stack = []
  // may want index or time?
  Mappy.prototype.add = function setOnMap(key, value) {
    if (this.has(key)) {
      key = key + random()
    }
    stack.push(value)
    return Map.prototype.set.call(this, key, value)
  }
  Mappy.prototype.debug = function() {
    // console.log(this)
    return JSON.stringify(fromMapToObj(this), null, 2)
  }
  Mappy.prototype.last = function() {
    return stack[stack.length]
  }
  // Object.defineProperty(Mappy.prototype, 'debug', {
  //   configurable: false,
  //   enumerable: false,
  //   writable: false,
  //   value() {
  //   },
  // })

  return Mappy
})(Map)

export { UniqueDictionary }
export default UniqueDictionary