File: /home/frenchy/www/french-american.org/current/node_modules/uglyfly-js/lib/defaults.js
/***********************************************************************
Copyright 2014 (c) Saair Quaderi <saair.quaderi@gmail.com>
Copyright 2012-2013 (c) Mihai Bazon <mihai.bazon@gmail.com>
UglyflyJS sourcecode can be found here:
https://github.com/quaderi/uglyflyjs
UglyflyJS (by Saair) is a fork of UglifyJS2 (by Mihai Bazon)
Both libraries are released under the BSD 2-Clause License.
***********************************************************************/
/*globals define, module, require */
((typeof define === "function") ? define :
function () { "use strict"; require('./nd').apply(module, arguments); })(
"defaults",
[
"DefaultsError"
],
function (DefaultsError) {
"use strict";
function defaults(args, defs, croak) {
var i,
ret;
if (args === true) {
args = {};
}
ret = args || {};
if (croak) {
if (typeof croak !== "function") {
croak = DefaultsError.croak;
} else if (croak !== DefaultsError.croak){
croak = (function (croak_callback) {
return function croak(msg, defs) {
croak_callback.apply(null, arguments);
throw new DefaultsError(msg, defs);
};
} (croak));
}
for (i in ret) {
if (ret.hasOwnProperty(i) && !defs.hasOwnProperty(i)) {
croak("`" + i + "` is not a supported option", defs);
}
}
}
for (i in defs) {
if (defs.hasOwnProperty(i)) {
ret[i] = (args && args.hasOwnProperty(i)) ? args[i] : defs[i];
}
}
return ret;
}
return defaults;
}
);