-
Notifications
You must be signed in to change notification settings - Fork 16
/
hamt.js.map
1 lines (1 loc) · 42.7 KB
/
hamt.js.map
1
{"version":3,"sources":["hamt.js"],"names":["hamt","SIZE","BUCKET_SIZE","Math","pow","MASK","MAX_INDEX_NODE","MIN_ARRAY_NODE","defaultValBind","f","defaultValue","x","arguments","length","hash","type","str","i","len","c","charCodeAt","popcount","hashFragment","shift","h","toBitmap","fromBitmap","bitmap","bit","arrayUpdate","at","v","arr","out","Array","arraySpliceOut","g","arraySpliceIn","LEAF","COLLISION","INDEX","ARRAY","Leaf","key","value","_modify","Leaf__modify","Collision","children","Collision__modify","IndexedNode","mask","IndexedNode__modify","ArrayNode","size","ArrayNode__modify","isLeaf","node","expand","frag","child","subNodes","count","pack","removed","elements","elem","mergeLeaves","h1","n1","h2","n2","subH1","subH2","updateCollisionList","list","op","k","__hamt_delete_op","newValue","__hamt_set_op","undefined","currentValue","indx","exists","newChild","empty__modify","current","_","Map","root","prototype","__hamt_isMap","setTree","tryGetHash","alt","map","tryGet","getHash","get","nothing","hasHash","has","empty","isMap","isEmpty","modifyHash","newRoot","modify","modifyValueHash","modifyValue","setHash","set","del","removeHash","deleteHash","remove","delete","appk","lazyVisitChildren","lazyVisit","rest","DONE","done","MapIterator","next","v0","Symbol","iterator","visit","buildPairs","entries","buildKeys","keys","buildValues","values","fold","z","m","toVisit","forEach","module","exports","define","amd"],"mappings":";;;;AAAA;;;;;AAKA,IAAMA,OAAO,EAAb,C,CAAiB;;AAEjB;;AAEA,IAAMC,OAAO,CAAb;;AAEA,IAAMC,cAAcC,KAAKC,GAAL,CAAS,CAAT,EAAYH,IAAZ,CAApB;;AAEA,IAAMI,OAAOH,cAAc,CAA3B;;AAEA,IAAMI,iBAAiBJ,cAAc,CAArC;;AAEA,IAAMK,iBAAiBL,cAAc,CAArC;;AAEA;;AAEA,IAAMM,iBAAiB,SAAjBA,cAAiB,CAACC,CAAD,EAAIC,YAAJ;AAAA,WACnB,UAASC,CAAT,EAAY;AAC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UAAU5I,KAAK4I,OAAL,GAAe,UAACnI,CAAD,EAAIuF,GAAJ;AAAA,WAC3BwC,KAAK,UAAChD,CAAD,EAAI5C,KAAJ,EAAWD,GAAX;AAAA,eAAmBlC,EAAEmC,KAAF,EAASD,GAAT,EAAcqD,GAAd,CAAnB;AAAA,KAAL,EAA4C,IAA5C,EAAkDA,GAAlD,CAD2B;AAAA,CAA/B;;AAGAP,IAAIE,SAAJ,CAAciD,OAAd,GAAwB,UAASnI,CAAT,EAAY;AAChC,WAAOmI,QAAQnI,CAAR,EAAW,IAAX,CAAP;AACH,CAFD;;AAIA;;AAEA;;;AAGA,IAAMqD,QAAQ9D,KAAK8D,KAAL,GAAa,UAACkC,GAAD;AAAA,WAASA,IAAI1C,IAAb;AAAA,CAA3B;;AAEAmC,IAAIE,SAAJ,CAAc7B,KAAd,GAAsB,YAAW;AAC7B,WAAOA,MAAM,IAAN,CAAP;AACH,CAFD;;AAIA;;AAEA,IAAI,OAAO+E,MAAP,KAAkB,WAAlB,IAAiCA,OAAOC,OAA5C,EAAqD;AACjDD,WAAOC,OAAP,GAAiB9I,IAAjB;AACH,CAFD,MAEO,IAAI,OAAO+I,MAAP,KAAkB,UAAlB,IAAgCA,OAAOC,GAA3C,EAAgD;AACnDD,WAAO,MAAP,EAAe,EAAf,EAAmB;AAAA,eAAM/I,IAAN;AAAA,KAAnB;AACH,CAFM,MAEA;AACH,cAAKA,IAAL,GAAYA,IAAZ;AACH","file":"hamt.js","sourcesContent":["/**\n @fileOverview Hash Array Mapped Trie.\n\n Code based on: https://github.com/exclipy/pdata\n*/\nconst hamt = {}; // export\n\n/* Configuration\n ******************************************************************************/\nconst SIZE = 5;\n\nconst BUCKET_SIZE = Math.pow(2, SIZE);\n\nconst MASK = BUCKET_SIZE - 1;\n\nconst MAX_INDEX_NODE = BUCKET_SIZE / 2;\n\nconst MIN_ARRAY_NODE = BUCKET_SIZE / 4;\n\n/*\n ******************************************************************************/\nconst defaultValBind = (f, defaultValue) =>\n function(x) {\n return f(arguments.length === 0 ? defaultValue : x);\n };\n\n/**\n Get 32 bit hash of string.\n\n Based on:\n http://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery\n*/\nconst hash = hamt.hash = str => {\n const type = typeof str;\n if (type === 'number')\n return str;\n if (type !== 'string')\n str += '';\n\n let hash = 0;\n for (let i = 0, len = str.length; i < len; ++i) {\n const c = str.charCodeAt(i);\n hash = (((hash << 5) - hash) + c) | 0;\n }\n return hash;\n};\n\n/* Bit Ops\n ******************************************************************************/\n/**\n Hamming weight.\n\n Taken from: http://jsperf.com/hamming-weight\n*/\nconst popcount = (x) => {\n x -= ((x >> 1) & 0x55555555);\n x = (x & 0x33333333) + ((x >> 2) & 0x33333333);\n x = (x + (x >> 4)) & 0x0f0f0f0f;\n x += (x >> 8);\n x += (x >> 16);\n return (x & 0x7f);\n};\n\nconst hashFragment = (shift, h) =>\n (h >>> shift) & MASK;\n\nconst toBitmap = x =>\n 1 << x;\n\nconst fromBitmap = (bitmap, bit) =>\n popcount(bitmap & (bit - 1));\n\n/* Array Ops\n ******************************************************************************/\n/**\n Set a value in an array.\n\n @param at Index to change.\n @param v New value\n @param arr Array.\n*/\nconst arrayUpdate = (at, v, arr) => {\n const len = arr.length;\n const out = new Array(len);\n for (let i = 0; i < len; ++i)\n out[i] = arr[i];\n out[at] = v;\n return out;\n};\n\n/**\n Remove a value from an array.\n\n @param at Index to remove.\n @param arr Array.\n*/\nconst arraySpliceOut = (at, arr) => {\n const len = arr.length;\n const out = new Array(len - 1);\n let i = 0, g = 0;\n while (i < at)\n out[g++] = arr[i++];\n ++i;\n while (i < len)\n out[g++] = arr[i++];\n return out;\n};\n\n/**\n Insert a value into an array.\n\n @param at Index to insert at.\n @param v Value to insert,\n @param arr Array.\n*/\nconst arraySpliceIn = (at, v, arr) => {\n const len = arr.length;\n const out = new Array(len + 1);\n let i = 0, g = 0;\n while (i < at)\n out[g++] = arr[i++];\n out[g++] = v;\n while (i < len)\n out[g++] = arr[i++];\n return out;\n};\n\n/* Node Structures\n ******************************************************************************/\nconst LEAF = 1;\nconst COLLISION = 2;\nconst INDEX = 3;\nconst ARRAY = 4;\n\n/**\n Leaf holding a value.\n\n @member hash Hash of key.\n @member key Key.\n @member value Value stored.\n*/\nconst Leaf = (hash, key, value) => ({\n type: LEAF,\n hash,\n key,\n value,\n _modify: Leaf__modify\n});\n\n/**\n Leaf holding multiple values with the same hash but different keys.\n\n @member hash Hash of key.\n @member children Array of collision children node.\n*/\nconst Collision = (hash, children) => ({\n type: COLLISION,\n hash,\n children,\n _modify: Collision__modify\n});\n\n/**\n Internal node with a sparse set of children.\n\n Uses a bitmap and array to pack children.\n\n @member mask Bitmap that encode the positions of children in the array.\n @member children Array of child nodes.\n*/\nconst IndexedNode = (mask, children) => ({\n type: INDEX,\n mask,\n children,\n _modify: IndexedNode__modify\n});\n\n/**\n Internal node with many children.\n\n @member size Number of children.\n @member children Array of child nodes.\n*/\nconst ArrayNode = (size, children) => ({\n type: ARRAY,\n size,\n children,\n _modify: ArrayNode__modify\n});\n\n/**\n Is `node` a leaf node?\n*/\nconst isLeaf = node =>\n (node.type === LEAF || node.type === COLLISION);\n\n/* Internal node operations.\n ******************************************************************************/\n/**\n Expand an indexed node into an array node.\n\n @param frag Index of added child.\n @param child Added child.\n @param mask Index node mask before child added.\n @param subNodes Index node children before child added.\n*/\nconst expand = (frag, child, bitmap, subNodes) => {\n const arr = [];\n let bit = bitmap;\n let count = 0;\n for (let i = 0; bit; ++i) {\n if (bit & 1)\n arr[i] = subNodes[count++];\n bit >>>= 1;\n }\n arr[frag] = child;\n return ArrayNode(count + 1, arr);\n};\n\n/**\n Collapse an array node into a indexed node.\n\n @param count Number of elements in new array.\n @param removed Index of removed element.\n @param elements Array node children before remove.\n*/\nconst pack = (count, removed, elements) => {\n const children = new Array(count - 1);\n let g = 0;\n let bitmap = 0;\n for (let i = 0, len = elements.length; i < len; ++i) {\n if (i !== removed) {\n const elem = elements[i];\n if (elem) {\n children[g++] = elem;\n bitmap |= 1 << i;\n }\n }\n }\n return IndexedNode(bitmap, children);\n};\n\n/**\n Merge two leaf nodes.\n\n @param shift Current shift.\n @param h1 Node 1 hash.\n @param n1 Node 1.\n @param h2 Node 2 hash.\n @param n2 Node 2.\n*/\nconst mergeLeaves = (shift, h1, n1, h2, n2) => {\n if (h1 === h2)\n return Collision(h1, [n2, n1]);\n\n const subH1 = hashFragment(shift, h1);\n const subH2 = hashFragment(shift, h2);\n return IndexedNode(toBitmap(subH1) | toBitmap(subH2),\n subH1 === subH2\n ? [mergeLeaves(shift + SIZE, h1, n1, h2, n2)]\n : subH1 < subH2 ? [n1, n2] : [n2, n1]);\n};\n\n/**\n Update an entry in a collision list.\n\n @param hash Hash of collision.\n @param list Collision list.\n @param op Update operation.\n @param k Key to update.\n @param size Size reference\n*/\nconst updateCollisionList = (h, list, op, k, size) => {\n const len = list.length;\n for (let i = 0; i < len; ++i) {\n const child = list[i];\n if (child.key === k) {\n const value = child.value;\n if (op.__hamt_delete_op) {\n --size.value\n return arraySpliceOut(i, list);\n }\n const newValue = op.__hamt_set_op ? op.value : op(value);\n if (newValue === value)\n return list;\n return arrayUpdate(i, Leaf(h, k, newValue), list);\n }\n }\n\n if (op.__hamt_delete_op)\n return list;\n const newValue = op.__hamt_set_op ? op.value : op();\n ++size.value;\n return arrayUpdate(len, Leaf(h, k, newValue), list);\n};\n\n/* Editing\n ******************************************************************************/\nconst Leaf__modify = function(shift, op, h, k, size) {\n if (k === this.key) {\n if (op.__hamt_delete_op) {\n --size.value;\n return undefined;\n }\n const currentValue = this.value;\n const newValue = op.__hamt_set_op ? op.value : op(currentValue);\n return newValue === currentValue ? this : Leaf(h, k, newValue);\n }\n if (op.__hamt_delete_op)\n return this;\n const newValue = op.__hamt_set_op ? op.value : op();\n ++size.value;\n return mergeLeaves(shift, this.hash, this, h, Leaf(h, k, newValue));\n};\n\nconst Collision__modify = function(shift, op, h, k, size) {\n if (h === this.hash) {\n const list = updateCollisionList(this.hash, this.children, op, k, size);\n if (list === this.children)\n return this;\n\n return list.length > 1\n ? Collision(this.hash, list)\n : list[0]; // collapse single element collision list\n }\n if (op.__hamt_delete_op)\n return this;\n const newValue = op.__hamt_set_op ? op.value : op();\n ++size.value;\n return mergeLeaves(shift, this.hash, this, h, Leaf(h, k, newValue));\n};\n\nconst IndexedNode__modify = function(shift, op, h, k, size) {\n const mask = this.mask;\n const children = this.children;\n const frag = hashFragment(shift, h);\n const bit = toBitmap(frag);\n const indx = fromBitmap(mask, bit);\n const exists = mask & bit;\n if (!exists) { // add\n const newChild = empty__modify(shift + SIZE, op, h, k, size);\n if (!newChild)\n return this;\n \n return children.length >= MAX_INDEX_NODE\n ? expand(frag, newChild, mask, children)\n : IndexedNode(\n mask | bit,\n arraySpliceIn(indx, newChild, children));\n }\n\n const current = children[indx];\n const newChild = current._modify(shift + SIZE, op, h, k, size);\n if (current === newChild)\n return this;\n\n if (!newChild) { // remove\n const bitmap = mask & ~bit;\n if (!bitmap) \n return undefined;\n \n return children.length === 2 && isLeaf(children[indx ^ 1])\n ? children[indx ^ 1] // collapse\n : IndexedNode(\n bitmap,\n arraySpliceOut(indx, children));\n }\n\n // modify\n return op.__hamt_delete_op && children.length === 1 && isLeaf(newChild)\n ? newChild // propagate collapse\n : IndexedNode(\n mask,\n arrayUpdate(indx, newChild, children));\n};\n\nconst ArrayNode__modify = function(shift, op, h, k, size) {\n const count = this.size;\n const children = this.children;\n const frag = hashFragment(shift, h);\n const child = children[frag];\n const newChild = child ? child._modify(shift + SIZE, op, h, k, size) : empty__modify(shift + SIZE, op, h, k, size);\n\n if (child === newChild)\n return this;\n\n if (!child && newChild) { // add\n return ArrayNode(\n count + 1,\n arrayUpdate(frag, newChild, children))\n }\n if (child && !newChild) { // remove\n return count - 1 <= MIN_ARRAY_NODE\n ? pack(count, frag, children)\n : ArrayNode(\n count - 1,\n arrayUpdate(frag, undefined, children))\n }\n\n // modify\n return ArrayNode(\n count,\n arrayUpdate(frag, newChild, children));\n};\n\nconst empty__modify = (_, op, h, k, size) => {\n if (op.__hamt_delete_op)\n return undefined;\n const newValue = op.__hamt_set_op ? op.value : op();\n ++size.value;\n return Leaf(h, k, newValue);\n};\n\n/*\n ******************************************************************************/\nfunction Map(root, size) {\n this.root = root;\n this.size = size;\n};\n\nMap.prototype.__hamt_isMap = true;\n\nMap.prototype.setTree = function(root, size) {\n return root === this.root ? this : new Map(root, size);\n};\n\n/* Queries\n ******************************************************************************/\n/**\n Lookup the value for `key` in `map` using a custom `hash`.\n\n Returns the value or `alt` if none.\n*/\nconst tryGetHash = hamt.tryGetHash = (alt, hash, key, map) => {\n if (!map.root)\n return alt;\n\n let node = map.root;\n let shift = 0;\n while (true) switch (node.type) {\n case LEAF:\n {\n return key === node.key ? node.value : alt;\n }\n case COLLISION:\n {\n if (hash === node.hash) {\n const children = node.children;\n for (let i = 0, len = children.length; i < len; ++i) {\n const child = children[i];\n if (key === child.key)\n return child.value;\n }\n }\n return alt;\n }\n case INDEX:\n {\n const frag = hashFragment(shift, hash);\n const bit = toBitmap(frag);\n if (node.mask & bit) {\n node = node.children[fromBitmap(node.mask, bit)];\n shift += SIZE;\n break;\n }\n return alt;\n }\n case ARRAY:\n {\n node = node.children[hashFragment(shift, hash)];\n if (node) {\n shift += SIZE;\n break;\n }\n return alt;\n }\n default:\n return alt;\n }\n};\n\nMap.prototype.tryGetHash = function(alt, hash, key) {\n return tryGetHash(alt, hash, key, this);\n};\n\n/**\n Lookup the value for `key` in `map` using internal hash function.\n\n @see `tryGetHash`\n*/\nconst tryGet = hamt.tryGet = (alt, key, map) =>\n tryGetHash(alt, hash(key), key, map);\n\nMap.prototype.tryGet = function(alt, key) {\n return tryGet(alt, key, this);\n};\n\n/**\n Lookup the value for `key` in `map` using a custom `hash`.\n\n Returns the value or `undefined` if none.\n*/\nconst getHash = hamt.getHash = (hash, key, map) =>\n tryGetHash(undefined, hash, key, map);\n\nMap.prototype.getHash = function(hash, key) {\n return getHash(hash, key, this);\n};\n\n/**\n Lookup the value for `key` in `map` using internal hash function.\n\n @see `get`\n*/\nconst get = hamt.get = (key, map) =>\n tryGetHash(undefined, hash(key), key, map);\n\nMap.prototype.get = function(key, alt) {\n return tryGet(alt, key, this);\n};\n\nconst nothing = ({});\n/**\n Does an entry exist for `key` in `map`? Uses custom `hash`.\n*/\nconst hasHash = hamt.has = (hash, key, map) =>\n tryGetHash(nothing, hash, key, map) !== nothing;\n\nMap.prototype.hasHash = function(hash, key) {\n return hasHash(hash, key, this);\n};\n\n/**\n Does an entry exist for `key` in `map`? Uses internal hash function.\n*/\nconst has = hamt.has = (key, map) =>\n hasHash(hash(key), key, map);\n\nMap.prototype.has = function(key) {\n return has(key, this);\n};\n\n/**\n Empty node.\n*/\nhamt.empty = new Map(undefined, 0);\n\n/**\n Is `value` a map?\n*/\nhamt.isMap = (value) =>\n !!(value && value.__hamt_isMap);\n\n/**\n Does `map` contain any elements?\n*/\nhamt.isEmpty = (map) =>\n hamt.isMap(map) && !map.root;\n\nMap.prototype.isEmpty = function() {\n return hamt.isEmpty(this);\n};\n\n\n/* Updates\n ******************************************************************************/\n/**\n Alter the value stored for `key` in `map` using function `f` using\n custom hash.\n\n `f` is invoked with the current value for `k` if it exists,\n or `defaultValue` if it is specified. Otherwise, `f` is invoked with no arguments\n if no such value exists.\n\n `modify` will always either update or insert a value into the map.\n\n Returns a map with the modified value. Does not alter `map`.\n*/\nconst modifyHash = hamt.modifyHash = (f, hash, key, map) => {\n const size = { value: map.size };\n const newRoot = map.root ? map.root._modify(0, f, hash, key, size) : empty__modify(0, f, hash, key, size);\n return map.setTree(newRoot, size.value);\n};\n\nMap.prototype.modifyHash = function(hash, key, f) {\n return modifyHash(f, hash, key, this);\n};\n\n/**\n Alter the value stored for `key` in `map` using function `f` using\n internal hash function.\n\n @see `modifyHash`\n*/\nconst modify = hamt.modify = (f, key, map) =>\n modifyHash(f, hash(key), key, map);\n\nMap.prototype.modify = function(key, f) {\n return modify(f, key, this);\n};\n\n/**\n Same as `modifyHash`, but invokes `f` with `defaultValue` if no entry exists.\n\n @see `modifyHash`\n*/\nconst modifyValueHash = hamt.modifyValueHash = (f, defaultValue, hash, key, map) =>\n modifyHash(defaultValBind(f, defaultValue), hash, key, map);\n\nMap.prototype.modifyValueHash = function(hash, key, f, defaultValue) {\n return modifyValueHash(f, defaultValue, hash, key, this);\n};\n\n/**\n @see `modifyValueHash`\n*/\nconst modifyValue = hamt.modifyValue = (f, defaultValue, key, map) =>\n modifyValueHash(f, defaultValue, hash(key), key, map);\n\nMap.prototype.modifyValue = function(key, f, defaultValue) {\n return modifyValue(f, defaultValue, key, this);\n};\n\n/**\n Store `value` for `key` in `map` using custom `hash`.\n\n Returns a map with the modified value. Does not alter `map`.\n*/\nconst setHash = hamt.setHash = function(hash, key, value, map) {\n return modifyHash({ __hamt_set_op: true, value: value }, hash, key, map);\n}\n\nMap.prototype.setHash = function(hash, key, value) {\n return setHash(hash, key, value, this);\n};\n\n/**\n Store `value` for `key` in `map` using internal hash function.\n\n @see `setHash`\n*/\nconst set = hamt.set = (key, value, map) =>\n setHash(hash(key), key, value, map);\n\nMap.prototype.set = function(key, value) {\n return set(key, value, this);\n};\n\n/**\n Remove the entry for `key` in `map`.\n\n Returns a map with the value removed. Does not alter `map`.\n*/\nconst del = { __hamt_delete_op: true };\nconst removeHash = hamt.removeHash = (hash, key, map) =>\n modifyHash(del, hash, key, map);\n\nMap.prototype.removeHash = Map.prototype.deleteHash = function(hash, key) {\n return removeHash(hash, key, this);\n};\n\n/**\n Remove the entry for `key` in `map` using internal hash function.\n\n @see `removeHash`\n*/\nconst remove = hamt.remove = (key, map) =>\n removeHash(hash(key), key, map);\n\nMap.prototype.remove = Map.prototype.delete = function(key) {\n return remove(key, this);\n};\n\n/* Traversal\n ******************************************************************************/\n/**\n Apply a continuation.\n*/\nconst appk = k =>\n k && lazyVisitChildren(k.len, k.children, k.i, k.f, k.k);\n\n/**\n Recursively visit all values stored in an array of nodes lazily.\n*/\nconst lazyVisitChildren = (len, children, i, f, k) => {\n while (i < len) {\n const child = children[i++];\n if (child)\n return lazyVisit(child, f, {len, children, i, f, k});\n }\n return appk(k);\n};\n\n/**\n Recursively visit all values stored in `node` lazily.\n*/\nconst lazyVisit = (node, f, k) => {\n if (node.type === LEAF) \n return { value: f(node), rest: k };\n\n const children = node.children;\n return lazyVisitChildren(children.length, children, 0, f, k);\n};\n\nconst DONE = { done: true };\n\n/**\n Javascript iterator over a map.\n*/\nfunction MapIterator(v) {\n this.v = v;\n};\n\nMapIterator.prototype.next = function() {\n if (!this.v)\n return DONE;\n const v0 = this.v;\n this.v = appk(v0.rest);\n return v0;\n};\n\nMapIterator.prototype[Symbol.iterator] = function() {\n return this;\n};\n\n/**\n Lazily visit each value in map with function `f`.\n*/\nconst visit = (map, f) =>\n new MapIterator(map.root ? lazyVisit(map.root, f) : undefined);\n\n/**\n Get a Javascript iterator of `map`.\n\n Iterates over `[key, value]` arrays.\n*/\nconst buildPairs = (x) => [x.key, x.value];\nconst entries = hamt.entries = (map) =>\n visit(map, buildPairs);\n\nMap.prototype.entries = Map.prototype[Symbol.iterator] = function() {\n return entries(this);\n};\n\n/**\n Get array of all keys in `map`.\n\n Order is not guaranteed.\n*/\nconst buildKeys = (x) => x.key;\nconst keys = hamt.keys = (map) =>\n visit(map, buildKeys);\n\nMap.prototype.keys = function() { return keys(this); }\n\n/**\n Get array of all values in `map`.\n\n Order is not guaranteed, duplicates are preserved.\n*/\nconst buildValues = x => x.value;\nconst values = hamt.values = Map.prototype.values = map =>\n visit(map, buildValues);\n\nMap.prototype.values = function() {\n return values(this);\n};\n\n/* Fold\n ******************************************************************************/\n/**\n Visit every entry in the map, aggregating data.\n\n Order of nodes is not guaranteed.\n\n @param f Function mapping accumulated value, value, and key to new value.\n @param z Starting value.\n @param m HAMT\n*/\nconst fold = hamt.fold = (f, z, m) => {\n const root = m.root;\n if (!root)\n return z;\n\n if (root.type === LEAF)\n return f(z, root.value, root.key);\n\n for (let toVisit = root; toVisit; ) {\n const children = toVisit.children;\n toVisit = toVisit.next;\n for (let i = 0, len = children.length; i < len;) {\n const child = children[i++];\n if (child) {\n if (child.type === LEAF)\n z = f(z, child.value, child.key);\n else\n toVisit = { children: child.children, next: toVisit } \n }\n }\n }\n return z;\n};\n\nMap.prototype.fold = function(f, z) {\n return fold(f, z, this);\n};\n\n/**\n Visit every entry in the map, aggregating data.\n\n Order of nodes is not guaranteed.\n\n @param f Function invoked with value and key\n @param map HAMT\n*/\nconst forEach = hamt.forEach = (f, map) =>\n fold((_, value, key) => f(value, key, map), null, map);\n\nMap.prototype.forEach = function(f) {\n return forEach(f, this);\n};\n\n/* Aggregate\n ******************************************************************************/\n/**\n Get the number of entries in `map`.\n*/\nconst count = hamt.count = (map) => map.size;\n\nMap.prototype.count = function() {\n return count(this);\n};\n\n/* Export\n ******************************************************************************/\nif (typeof module !== 'undefined' && module.exports) {\n module.exports = hamt;\n} else if (typeof define === 'function' && define.amd) {\n define('hamt', [], () => hamt);\n} else {\n this.hamt = hamt;\n}\n"]}