summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPeter Lejeck <peter.lejeck@gmail.com>2014-04-29 05:52:18 +0200
committerPeter Lejeck <peter.lejeck@gmail.com>2014-04-29 05:52:18 +0200
commit1913da9da6247e775482673fb2f57f888e7b910f (patch)
tree9324dfb1fe9a480499f7c8d212db029581dd972b /js
parentce62cf05c90408511d54d0819e73622078a98c08 (diff)
Genericize defaults function into merge utility
We're gonna use this shortly for the data field
Diffstat (limited to 'js')
-rw-r--r--js/cheesesteak.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/js/cheesesteak.js b/js/cheesesteak.js
index 378c6e8..a822623 100644
--- a/js/cheesesteak.js
+++ b/js/cheesesteak.js
@@ -94,10 +94,13 @@
})*/
// b gets merged as defaults for a
- var defaults = function (a, b) {
- var out = {}
- for (var key in b) {
- out[key] = (a[key] === void 0) ? b[key] : a[key]
+ var merge = function merge (base, overlay) {
+ var out = base
+ for (var key in overlay) {
+ if (typeof overlay[key] === 'object')
+ out[key] = merge(base[key], overlay[key]);
+ else
+ out[key] = overlay[key]
}
return out
}
@@ -108,10 +111,11 @@
opts = opts || {}
- this.opts = defaults(opts, {
+ this.opts = merge({
'field': 'files[]',
- 'method': 'POST'
- })
+ 'method': 'POST'
+ 'data': {}
+ }, opts)
}
FileListUploader.prototype = Object.create(EventEmitter.prototype)
FileListUploader.prototype.upload = function (cb) {