Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { generateUniqueNumber } from 'fast-unique-numbers';
import { AudioBuffer, AudioBufferSourceNode, MinimalAudioContext, isSupported } from 'standardized-audio-context';
import { TFunctionMap, TTimerType } from './types';
const MINIMAL_AUDIO_CONTEXT = new MinimalAudioContext();
const AUDIO_BUFFER = new AudioBuffer({ length: 2, sampleRate: MINIMAL_AUDIO_CONTEXT.sampleRate });
const SAMPLE_DURATION = 2 / MINIMAL_AUDIO_CONTEXT.sampleRate;
const SCHEDULED_TIMEOUT_FUNCTIONS: TFunctionMap = new Map();
const SCHEDULED_INTERVAL_FUNCTIONS: TFunctionMap = new Map();
const callIntervalFunction = (id: number, type: TTimerType) => {
const functions = (type === 'interval') ? SCHEDULED_INTERVAL_FUNCTIONS : SCHEDULED_TIMEOUT_FUNCTIONS;
if (functions.has(id)) {
const func = functions.get(id);
if (func !== undefined) {