How can I use CreateScriptProcessor for real time audio time stretching algorithm in JavaScript?

I want to use a time stretch Algorithm in my project but I don’t know where should I call my function TimeStretchAlgorithm().

const TimeStretchAlgorithm = (playbackspeed)=>{
 // algorithm codes
}


let node1 = audioCtx.createScriptProcessor(4096, 1, 1);
node1.onaudioprocess = function (e) {
   let inputBuffer = e.inputBuffer;
   let outputBuffer = e.outputBuffer;

   for (let channel = 0; channel < outputBuffer.numberOfChannels; channel++) {
        let inputData = inputBuffer.getChannelData(channel);
        let outputData = outputBuffer.getChannelData(channel);

        let playbackspeed = 0.7;
        outputData = TimeStretchAlgorithm(playbackspeed);
      }
  }