Added cache method for generators and new logging method for chains

This commit is contained in:
2023-12-14 21:48:46 +02:00
parent ee3d9a63e9
commit afa6457f88
7 changed files with 107 additions and 12 deletions

View File

@ -444,6 +444,25 @@ export abstract class AudibleEvent extends AbstractEvent {
}
};
public log = (key: string|string[], ...args: string[]) => {
/*
* Log values from values using log()
*
* @param key - The key(s) to log
* @returns this and logs the values
*/
if (typeof key === "string") {
if(args && args.length > 0) {
this.app.api.log([key, ...args].map((k) => this.values[k]));
} else {
this.app.api.log(this.values[key]);
}
} else {
this.app.api.log([...key, ...args].map((k) => this.values[k]));
}
return this;
}
freq = (value: number | number[], ...kwargs: number[]): this => {
/*
* This function is used to set the frequency of the Event.

View File

@ -5,7 +5,7 @@ import { SkipEvent } from "./SkipEvent";
import { SoundEvent, SoundParams } from "./SoundEvent";
import { MidiEvent, MidiParams } from "./MidiEvent";
import { RestEvent } from "./RestEvent";
import { GeneratorIteratorType, GeneratorType, arrayOfObjectsToObjectWithArrays } from "../Utils/Generic";
import { arrayOfObjectsToObjectWithArrays, isGenerator } from "../Utils/Generic";
import { TonnetzSpaces } from "zifferjs/src/tonnetz";
export type InputOptions = { [key: string]: string | number };
@ -40,7 +40,7 @@ export class Player extends AbstractEvent {
} else if (typeof input === "number") {
this.input = input;
this.ziffers = Ziffers.fromNumber(input, options);
} else if (input.constructor === GeneratorType || input.constructor === GeneratorIteratorType){
} else if (isGenerator(input)) {
this.ziffers = Ziffers.fromGenerator(input, options);
this.input = this.ziffers.input;
} else {