bsh-circular-buffer
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.5 • Public • Published

    Summary

    A basic Circular Buffer implementation

    import { CircularBuffer, CircularBufferOptions } from "bsh-circular-buffer";
    
    const numberIterator = () => {
      return Math.floor(Math.random() * 1000);
    };
    
    const options: CircularBufferOptions<number> = {
      interval: 250,
      iterator: numberIterator,
      size: 8,
    };
    
    const buf = new CircularBuffer(options);
    buf.start();
    
    const timer = setInterval(() => {
      const vals = buf.values();
      console.log("vals:", vals);
    }, 500);
    
    setTimeout(() => {
      buf.stop();
      clearInterval(timer);
    }, 4000);
    

    Keywords

    none

    Install

    npm i bsh-circular-buffer

    DownloadsWeekly Downloads

    1

    Version

    1.0.5

    License

    ISC

    Unpacked Size

    8.29 kB

    Total Files

    12

    Last publish

    Collaborators

    • euchremylucre