New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@telemok/ring-buffer-uint8array

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@telemok/ring-buffer-uint8array

Typescript circular ring buffer uint8array with push shift read write find operations

latest
npmnpm
Version
0.2023.1-2.2
Version published
Maintainers
1
Created
Source

ring-buffer-uint8array (RingBufferUint8Array)

https://npmjs.com/package/@telemok/ring-buffer-uint8array is the typescript circular ring buffer uint8array with .push .shift .read .write find operations

Features

  • Work in Uint8array - it faster and native.
  • UART/USART stream parsing compatible.
  • Argument checking and fast functions without checking.
  • Fast and easy to learn.
  • Ring overwrite on/off.
  • Any buffer size, not 2^n.
  • NodeJs and browser Javascript support

Installation:

  • Create your NodeJs, Browser or Webview app.
  • run: npm install @telemok/ring-buffer-uint8array
  • import { RingBufferUint8Array } from "@telemok/RingBufferUint8Array.ts"
  • Ready.

Examples:

  • Parsing students database
import {RingBufferUint8Array} from "@telemok/RingBufferUint8Array"

const textEncoder = new TextEncoder();
const textDecoder = new TextDecoder();

/* Create instance of RingBuffer */
let rb = new RingBufferUint8Array(10);

/* Data to parse, like streaming from UART. */
const inputStream = "Hello\r\nworld! May be.";

/* Separators to split data. */
const binarySeparators = [textEncoder.encode('\r\n'), textEncoder.encode('!')];

/* Iterate stream data.*/
for(let c of inputStream)
{
    /* Push bytes from stream. */
    rb.pushByte(textEncoder.encode(c)[0]);
    
    /* Extract Uint8array from ringbuffer without separator if separator match or return null. */
    let arr = rb.ifEndsWithUint8ArraysThenFlushUint8Array(binarySeparators, false);
    if(arr !== null)
        console.log("Find: ", textDecoder.decode(arr));
}

It will return:
Find: Hello
Find: world

Keywords

buffer

FAQs

Package last updated on 17 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts