Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function clean(spec, internal: boolean) {
let cleanKey;
for (const [key, prop] of Object.entries(spec)) {
cleanKey = key.startsWith('_');
cleanKey = cleanKey || prop === null || prop === undefined || (prop as any)._disabled;
if (cleanKey) {
delete spec[key];
} else if (key === 'name' && isString(prop)) {
spec[key] = name(prop);
} else if (isObject(prop)) {
if ((prop as any).signal && !internal) {
// Render signals to their value
spec[key] = signalLookup((prop as any).signal);
} else {
// Recurse
spec[key] = clean(spec[key], internal);
}
}
}
return spec;
}
const wrapper: Wrapper = (...args: any[]): any => {
if (args.length > 1 && ((isString(args[0]) && !isURL(args[0])) || isElement(args[0]) || args.length === 3)) {
return embed(args[0], args[1], args[2]);
}
return container(args[0], args[1]);
};