dict: Make set() return the value passed

We were accidentally leaking our internal representation.

(imported from commit 08ddc42583fb13a2ad51eea7ed1b30bf5ccb4645)
This commit is contained in:
Zev Benjamin 2013-08-20 16:34:36 -04:00
parent 707898b236
commit 62aec87962
2 changed files with 6 additions and 1 deletions

View File

@ -57,7 +57,8 @@ Dict.prototype = _.object(_.map({
},
set: function Dict_set(key, value) {
return (this._items[this._munge(key)] = {k: key, v: value});
this._items[this._munge(key)] = {k: key, v: value};
return value;
},
has: function Dict_has(key) {

View File

@ -31,6 +31,10 @@ var _ = global._;
assert.strictEqual(d.get('bar'), undefined);
assert.deepEqual(d.keys(), ['foo']);
var val = ['foo'];
var res = d.set('abc', val);
assert.equal(val, res);
}());
(function test_restricted_keys() {