UNPKG

paypal-checkout

Version:

PayPal Checkout components, for integrating checkout products.

29 lines (20 loc) 734 B
/* @flow */ export function extendNamespace(xports : Object, namespaces : $ReadOnlyArray<string> = [], childnamespaces : $ReadOnlyArray<string> = []) : Object { for (const name of namespaces) { const namespace = window[name]; if (!namespace) { continue; } for (const childname of childnamespaces) { let childnamespace = xports[childname]; if (namespace[childname]) { childnamespace = { ...namespace[childname], ...childnamespace }; } xports = { ...namespace, ...xports, [ childname ]: childnamespace }; } } for (const name of namespaces) { window[name] = xports; } return xports; }