Add register to API for registering reusable function chains

This commit is contained in:
2023-11-16 22:39:51 +02:00
parent 02fc13803f
commit 9c362d6a5d
4 changed files with 35 additions and 22 deletions

View File

@ -29,6 +29,7 @@ import { Speaker } from "./extensions/StringExtensions";
import { getScaleNotes } from "zifferjs";
import { OscilloscopeConfig, blinkScript } from "./AudioVisualisation";
import { SkipEvent } from "./classes/SkipEvent";
import { AbstractEvent, EventOperation } from "./classes/AbstractEvents";
interface ControlChange {
channel: number;
@ -1897,6 +1898,12 @@ export class UserAPI {
// High Order Functions
// =============================================================
register = (name: string, operation: EventOperation<AbstractEvent>): void => {
AbstractEvent.prototype[name] = function (this: AbstractEvent) {
return operation(this);
};
}
public shuffle = <T>(array: T[]): T[] => {
/**
* Returns a shuffled version of an array.