Index: src/collection.js |
diff --git a/src/collection.js b/src/collection.js |
index 6b468f5fc0ee8b2de8cd61ca1a27e4c78c8dcfb5..1c6b475df6cf4761f4d25738150b1d3bfa3c44d5 100644 |
--- a/src/collection.js |
+++ b/src/collection.js |
@@ -4,6 +4,8 @@ |
var $getHash; |
var $getExistingHash; |
+var $mapFromArray; |
+var $setFromArray; |
(function(global, utils) { |
"use strict"; |
@@ -480,4 +482,23 @@ utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ |
$getHash = GetHash; |
$getExistingHash = GetExistingHash; |
+$mapFromArray = function(array) { |
+ var map = new GlobalMap; |
+ var length = array.length; |
+ for (var i = 0; i < length; ++i) { |
+ var entry = array[i]; |
+ %_CallFunction(map, entry[0], entry[1], MapSet); |
+ } |
+ return map; |
+}; |
+ |
+$setFromArray = function(array) { |
+ var set = new GlobalSet; |
+ var length = array.length; |
+ for (var i = 0; i < length; ++i) { |
+ %_CallFunction(set, array[i], SetAdd); |
+ } |
+ return set; |
+}; |
+ |
}) |