Comparing version 0.0.3 to 0.0.4
@@ -57,2 +57,3 @@ /* | ||
var self = this; | ||
(self.edit = edit); | ||
(self.hash = hash0); | ||
@@ -76,3 +77,3 @@ (self.children = children); | ||
}), | ||
expand = (function(edit, frag, child, bitmap, subNodes) { | ||
expand = (function(edit, frag, child, bitmap, children) { | ||
var bit = bitmap, | ||
@@ -84,3 +85,3 @@ arr = [], | ||
if ((bit & 1)) { | ||
(arr[i] = subNodes[count]); | ||
(arr[i] = children[count]); | ||
(count = (count + 1)); | ||
@@ -93,15 +94,15 @@ } | ||
}), | ||
pack = (function(edit, removed, elements) { | ||
var children = [], | ||
pack = (function(edit, removed, children) { | ||
var packed = [], | ||
bitmap = 0; | ||
for (var i = 0, len = elements.length; | ||
for (var i = 0, len = children.length; | ||
(i < len); | ||
(i = (i + 1))) { | ||
var elem = elements[i]; | ||
var elem = children[i]; | ||
if (((i !== removed) && (!(!elem)))) { | ||
children.push(elem); | ||
packed.push(elem); | ||
(bitmap = (bitmap | (1 << i))); | ||
} | ||
} | ||
return new(IndexedNode)(edit, bitmap, children); | ||
return new(IndexedNode)(edit, bitmap, packed); | ||
}), | ||
@@ -218,11 +219,2 @@ mergeLeaves = (function(edit, shift, n1, n2) { | ||
})); | ||
var updateIndexedNode = (function(mutate0, node, edit, bitmap, children) { | ||
if (mutate0) { | ||
(node.mask = bitmap); | ||
(node.children = children); | ||
return node; | ||
} else { | ||
return new(IndexedNode)(edit, bitmap, children); | ||
} | ||
}); | ||
(IndexedNode.prototype.modify = (function(mutate0, eq, edit, shift, f, h, k) { | ||
@@ -242,37 +234,50 @@ var self = this, | ||
return null; | ||
} else if (removed) { | ||
} | ||
var newChildren; | ||
if (removed) { | ||
if (((children.length <= 2) && isLeaf(children[(indx ^ 1)]))) { | ||
return children[(indx ^ 1)]; | ||
} | ||
return updateIndexedNode(e, self, edit, bitmap0, arraySpliceOut(e, indx, self.children)); | ||
(newChildren = arraySpliceOut(e, indx, children)); | ||
} else if (added) { | ||
if ((self.children.length >= MAX_INDEX_NODE)) return expand(edit, frag, child, self.mask, children); | ||
return updateIndexedNode(e, self, edit, bitmap0, arraySpliceIn(e, indx, child, self.children)); | ||
(newChildren = arraySpliceIn(e, indx, child, children)); | ||
} else { | ||
return updateIndexedNode(e, self, edit, bitmap0, arrayUpdate(e, indx, child, self.children)); | ||
(newChildren = arrayUpdate(e, indx, child, children)); | ||
} | ||
})); | ||
var updateArrayNode = (function(mutate0, node, edit, count, children) { | ||
if (mutate0) { | ||
(node.count = count); | ||
(node.children = children); | ||
return node; | ||
if (e) { | ||
(self.mask = bitmap0); | ||
(self.children = newChildren); | ||
return self; | ||
} else { | ||
return new(ArrayNode)(edit, count, children); | ||
return new(IndexedNode)(edit, bitmap0, newChildren); | ||
} | ||
}); | ||
})); | ||
(ArrayNode.prototype.modify = (function(mutate0, eq, edit, shift, f, h, k) { | ||
var self = this, | ||
x, x0, x1, x2, e = (mutate0 && (edit === self.edit)), | ||
count = self["count"], | ||
children = self["children"], | ||
node, x, x0, x1, x2, e = (mutate0 && ((node = self), (edit === node.edit))), | ||
frag = ((h >>> shift) & mask), | ||
child = self.children[frag], | ||
newChild = alter(e, eq, edit, child, (shift + 5), f, h, k); | ||
child = children[frag], | ||
newChild = alter(e, eq, edit, child, (shift + 5), f, h, k), | ||
newCount, newChildren; | ||
if ((((x = child), (!x)) && (!((x0 = newChild), (!x0))))) { | ||
return updateArrayNode(e, self, edit, (self.count + 1), arrayUpdate(e, frag, newChild, self.children)); | ||
(newCount = (count + 1)); | ||
(newChildren = arrayUpdate(e, frag, newChild, children)); | ||
} else if (((!((x1 = child), (!x1))) && ((x2 = newChild), (!x2)))) { | ||
if (((self.count - 1) <= MIN_ARRAY_NODE)) return pack(edit, frag, self.children); | ||
return updateArrayNode(e, self, edit, (self.count - 1), arrayUpdate(e, frag, null, self.children)); | ||
(newCount = (count - 1)); | ||
(newChildren = arrayUpdate(e, frag, null, children)); | ||
} else { | ||
return updateArrayNode(e, self, edit, self.count, arrayUpdate(e, frag, newChild, self.children)); | ||
(newCount = count); | ||
(newChildren = arrayUpdate(e, frag, newChild, children)); | ||
} | ||
if (e) { | ||
(self.count = newCount); | ||
(self.children = newChildren); | ||
return self; | ||
} else { | ||
return new(ArrayNode)(edit, newCount, newChildren); | ||
} | ||
})); | ||
@@ -279,0 +284,0 @@ (alter = (function(mutate0, eq, edit, n, shift, f, h, k) { |
{ | ||
"name": "hamt_plus", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Fork of HAMT that adds a transaction interface and support for custom key types", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37167
419