mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
20 lines
563 B
TypeScript
20 lines
563 B
TypeScript
function optionsFromArguments<Options>(defaults: Options, args: any[], keys: string[]): Options {
|
|
return defaults;
|
|
}
|
|
|
|
type ObjectConstructor = new (...args: any[]) => {};
|
|
|
|
export function useDefaultsAndArguments<DefaultOptions>(
|
|
defaults: DefaultOptions,
|
|
optionsOrder: string[],
|
|
) {
|
|
return <T extends ObjectConstructor>(classDef: T) => {
|
|
return class extends classDef {
|
|
// assign the instance defaults
|
|
defaults: DefaultOptions = defaults;
|
|
constructor(...args: any[]) {
|
|
super(optionsFromArguments(defaults, args, optionsOrder));
|
|
}
|
|
};
|
|
};
|
|
}
|