mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
implemented level load, more to do see #1
This commit is contained in:
parent
b02036a019
commit
953159e6bd
12 changed files with 333 additions and 409 deletions
46
app/Lib/Utilities/Options.js
Normal file
46
app/Lib/Utilities/Options.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
define([
|
||||
"Lib/Utilities/Exception"
|
||||
],
|
||||
|
||||
function (Exception) {
|
||||
|
||||
function Options() {
|
||||
|
||||
}
|
||||
|
||||
Options.prototype.merge = function(options, preset) {
|
||||
|
||||
if(!preset && !options) {
|
||||
throw new Exception("Options requires objects");
|
||||
}
|
||||
|
||||
if(preset.constructor !== Object && options.constructor !== Object) {
|
||||
throw new Exception("Options requires objects");
|
||||
}
|
||||
|
||||
if(!preset || preset.constructor !== Object) {
|
||||
return options;
|
||||
}
|
||||
|
||||
if(!options || options.constructor !== Object) {
|
||||
return preset;
|
||||
}
|
||||
|
||||
for (var key in options) {
|
||||
if(!preset.hasOwnProperty(key)) {
|
||||
preset[key] = options[key];
|
||||
} else {
|
||||
if(options[key].constructor !== Object) {
|
||||
preset[key] = options[key];
|
||||
} else {
|
||||
preset[key] = mergeOptions(options[key], preset[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return preset;
|
||||
}
|
||||
|
||||
return new Options();
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue