mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 01:38:07 +08:00
R=jacktfranklin@chromium.org Bug: 1213034 Change-Id: I5da8225f60b53870a1c67d6b5d02a464c08f4eb2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2917088 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
58 lines
845 B
JavaScript
58 lines
845 B
JavaScript
"use strict";
|
|
|
|
var objUtils = require("./util/object");
|
|
|
|
|
|
|
|
function getOptions(options, defaults)
|
|
{
|
|
if ( objUtils.isPlainObject(options) )
|
|
{
|
|
var newOptions = {};
|
|
|
|
for (var i in defaults)
|
|
{
|
|
if ( defaults.hasOwnProperty(i) )
|
|
{
|
|
if (options[i] !== undefined)
|
|
{
|
|
newOptions[i] = mergeOption(options[i], defaults[i]);
|
|
}
|
|
else
|
|
{
|
|
newOptions[i] = defaults[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
return newOptions;
|
|
}
|
|
else
|
|
{
|
|
return defaults;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function mergeOption(newValues, defaultValues)
|
|
{
|
|
if (defaultValues instanceof Object && newValues instanceof Object)
|
|
{
|
|
if (defaultValues instanceof Array && newValues instanceof Array)
|
|
{
|
|
return defaultValues.concat(newValues);
|
|
}
|
|
else
|
|
{
|
|
return objUtils.shallowMerge(newValues, defaultValues);
|
|
}
|
|
}
|
|
|
|
return newValues;
|
|
}
|
|
|
|
|
|
|
|
module.exports = getOptions;
|