set.up
v0.0.0
Published
sets, upgraded
Readme
Collection tools
Creates 2 new objects, setUp and mapUp, each with 2 methods, setUp.shim() and mapUp.shim() adds all of these to Set.prototype or Map.prototype (if they are not already there) while setUp._() and mapUp._() add them prefixed with an underscore.
Currently only works in firefox as V8 does not have iteration of Set and Map yet, and IE has yet to produce a browser that will run on any of my computers.
Set API
stuff from Array.prototype
these are all identical to their version on array, the only differences being the functions are not called with index as an argument and length is not cached at the beginning so values may be added during iteration.
Set.prototype.mapSet.prototype.filterSet.prototype.reduceSet.prototype.someSet.prototype.every
new stuff
Set.prototype.equalstakes another set, returns true if they are the same size and the other set has all the same values as this set.Set.prototype.mergetakes one or more sets as arguments, returns a new set which merges those sets to this one.Set.prototype.appendtakes one or more sets as arguments, adds their values to the current set and returns it.Set.prototype.unionpoints to mergeSet.prototype.toArrayreturns the values of the set, results are sorted and it takes an optional sort function.Set.prototype.intersectiontakes another set, returns a new set with only those values that are in both.Set.prototype.xortakes another set, returns a new set only those values that are in just one set.Set.prototype.symmetricDifferencesame as xorSet.prototype.complimenttakes another set, returns a new set with all those items in the first set, but not in the second set
Map API
the same as the set stuff but every callback that took a value for set takes a value, key for Map
Map.prototype.mapreturns a setMap.prototype.filterMap.prototype.reducefunction called accumulator, value, key, map, if no accumulator is given as argument first VALUE is usedMap.prototype.someMap.prototype.everyMap.prototype.equalsMap.prototype.mergeif the value is already in the map it is not replacedMap.prototype.appendif the value is already in the map it is not replacedMap.prototype.toObjectturns it into an object, some of the keys may be stringified
