aboutsummaryrefslogtreecommitdiff
path: root/lib/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/utils.js b/lib/utils.js
index 7c6a1563..4612a322 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -106,10 +106,12 @@ function defaults(args, defs, croak) {
};
function merge(obj, ext) {
+ var count = 0;
for (var i in ext) if (ext.hasOwnProperty(i)) {
obj[i] = ext[i];
+ count++;
}
- return obj;
+ return count;
};
function noop() {};
@@ -298,5 +300,11 @@ Dictionary.prototype = {
for (var i in this._values)
ret.push(f(this._values[i], i.substr(1)));
return ret;
- }
+ },
+ toObject: function() { return this._values }
+};
+Dictionary.fromObject = function(obj) {
+ var dict = new Dictionary();
+ dict._size = merge(dict._values, obj);
+ return dict;
};