aboutsummaryrefslogtreecommitdiff
path: root/lib/utils.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-04-17 08:13:49 +0100
committerGitHub <noreply@github.com>2020-04-17 15:13:49 +0800
commit9110fac9a28d18981e2297f4c84f4c18037ba88e (patch)
treeb71144f6a348e347758ab99649526c434e2879d0 /lib/utils.js
parent83f42ede367316193205572a04959098b45e711d (diff)
downloadtracifyjs-9110fac9a28d18981e2297f4c84f4c18037ba88e.tar.gz
tracifyjs-9110fac9a28d18981e2297f4c84f4c18037ba88e.zip
suppress mutation of input `options` (#3785)
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/utils.js b/lib/utils.js
index 508aba9c..7932e05f 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -87,15 +87,11 @@ DefaultsError.prototype.name = "DefaultsError";
configure_error_stack(DefaultsError);
function defaults(args, defs, croak) {
- if (args === true) args = {};
- var ret = args || {};
- if (croak) for (var i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
- throw new DefaultsError("`" + i + "` is not a supported option", defs);
+ for (var i in args) if (HOP(args, i)) {
+ if (croak && !HOP(defs, i)) throw new DefaultsError("`" + i + "` is not a supported option", defs);
+ defs[i] = args[i];
}
- for (var i in defs) if (HOP(defs, i)) {
- ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
- }
- return ret;
+ return defs;
}
function merge(obj, ext) {