Repository URL to install this package:
|
Version:
1.2.20 ▾
|
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