JSPM

cirbuf

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 421
    • Score
      100M100P100Q91206F
    • License MIT

    A tiny and fast circular buffer

    Package Exports

    • cirbuf
    • cirbuf/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cirbuf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    cirbuf

    A tiny and fast circular buffer

    • Minimal API
    • Tiny size fit for the browser
    • Fast

    Install

    npm install --save cirbuf

    Usage

    // Import CircularBuffer
    import { CircularBuffer } from "cirbuf"
    
    // Create a buffer with a capacity of 10,000
    const buffer = new CircularBuffer(10_000)
    
    // Push 100,000 items
    for (let i = 0; i < 100_000; i++) {
        buffer.push(i)
    }
    
    // Get the last 10,000 items as an array
    const result = buffer.toArray()
    // Note: `toArray` does not drain the buffer.