@datalayer/core
Version:
[](https://datalayer.io)
20 lines (19 loc) • 674 B
JavaScript
/*
* Copyright (c) 2023-2025 Datalayer, Inc.
* Distributed under the terms of the Modified BSD License.
*/
/**
* Apply mixins to a base class.
* @param derivedCtor - The base class to extend
* @param constructors - Array of mixin classes to apply
*/
export function applyMixins(derivedCtor, constructors) {
constructors.forEach(baseCtor => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
if (name !== 'constructor') {
Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||
Object.create(null));
}
});
});
}