UNPKG

ziko

Version:

a versatile javaScript framework offering a rich set of UI components, advanced mathematical utilities, reactivity, animations, client side routing and graphics capabilities

16 lines (13 loc) 469 B
export function composeInstance(instance, mixin) { const descriptors = Object.getOwnPropertyDescriptors(mixin); for (const key of Reflect.ownKeys(descriptors)) { const desc = descriptors[key]; if ('get' in desc || 'set' in desc) { Object.defineProperty(instance, key, desc); } else if (typeof desc.value === 'function') { instance[key] = desc.value.bind(instance); } else { instance[key] = desc.value; } } }