1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Use _.extend instead of the hand-rolled merge

This commit is contained in:
Jeremy Ashkenas 2010-02-13 08:50:29 -05:00
parent 8c077f0f65
commit dd6be80fca
2 changed files with 9 additions and 23 deletions

View file

@ -25,24 +25,11 @@
return memo;
};
// Merge objects.
merge = function merge(src, dest) {
var __a, __b, fresh, key, val;
fresh = {};
__a = src;
for (key in __a) {
val = __a[key];
if (__hasProp.call(__a, key)) {
((fresh[key] = val));
}
}
__b = dest;
for (key in __b) {
val = __b[key];
if (__hasProp.call(__b, key)) {
((fresh[key] = val));
}
}
return fresh;
merge = function merge(options, overrides) {
return _.tap({}, function(fresh) {
_.extend(fresh, options);
return _.extend(fresh, overrides);
});
};
// Delete a key from an object, returning the value.
del = function del(obj, key) {

View file

@ -20,11 +20,10 @@ flatten: (list) ->
memo
# Merge objects.
merge: (src, dest) ->
fresh: {}
(fresh[key]: val) for key, val of src
(fresh[key]: val) for key, val of dest
fresh
merge: (options, overrides) ->
_.tap {}, (fresh) ->
_.extend fresh, options
_.extend fresh, overrides
# Delete a key from an object, returning the value.
del: (obj, key) ->