npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ts-overflow/buffer

v1.0.1

Published

This module provides interfaces and methods for working with polymorphic buffers in TypeScript. Polymorphic buffers are versatile data structures that can be initialized from various sources, such as strings, byte arrays, or existing buffers.

Downloads

2

Readme

Polymorphic Buffer

This module provides interfaces and methods for working with polymorphic buffers in TypeScript. Polymorphic buffers are versatile data structures that can be initialized from various sources, such as strings, byte arrays, or existing buffers.

Installation

To install the module, you can use npm:

npm install --save @ts-overflow/buffer

or using yarn:

yarn add @ts-overflow/buffer

Usage

import Buffer from '@ts-overflow/buffer';

// Example usage of the interfaces and methods provided by the module
// Instantiate a new PolymorphicBuffer
const buf = Buffer.alloc(10);

// Manipulate the buffer
buf.writeUInt32BE(123, 0);

console.log(buf.toString('hex')); // Output: 0000007b

// More examples can be found in the documentation below.

API Documentation

Interface: PolymorphicBufferConstructor

Methods

alloc(byteLength: number): PolymorphicBuffer: Allocates a new PolymorphicBuffer of specified byte length.

wrap(actual: Uint8Array): PolymorphicBuffer: Wraps the given Uint8Array in a PolymorphicBuffer instance.

fromString(str: string, options?: BufferInitOptions): PolymorphicBuffer: Creates a new PolymorphicBuffer instance from the given string.

fromByteArray(source: number[]): PolymorphicBuffer: Creates a new PolymorphicBuffer instance from the given array of bytes.

fromBinaryTail(binaryTail: string): PolymorphicBuffer: Creates a new PolymorphicBuffer instance from the given binary tail string.

concat(buffers: PolymorphicBuffer[], totalLength?: number): PolymorphicBuffer: Creates a new PolymorphicBuffer instance from the given array of PolymorphicBuffer instances.

fromNodeBuffer(buffer: Buffer, options?: Omit<BufferInitOptions, 'dontUseNodeBuffer'>): PolymorphicBuffer: Creates a new PolymorphicBuffer instance from the given Buffer.

fromUint8Array(buffer: Uint8Array, options?: Omit<BufferInitOptions, 'dontUseNodeBuffer'>): PolymorphicBuffer: Creates a new PolymorphicBuffer instance from the given Uint8Array.

Interface: PolymorphicBuffer

Properties

buffer: Uint8Array: The backing store Uint8Array of this PolymorphicBuffer instance.

byteLength: number: The number of bytes in this PolymorphicBuffer.

length: number: The number of items in this PolymorphicBuffer. Methods

slice(start?: number, end?: number): PolymorphicBuffer: Creates a new PolymorphicBuffer instance with a section of this PolymorphicBuffer.

clone(): PolymorphicBuffer: Copies this PolymorphicBuffer instance into a new PolymorphicBuffer instance.

set(array: PolymorphicBuffer | Uint8Array | ArrayBuffer | ArrayBufferView, offset?: number): void: Sets the bytes in this PolymorphicBuffer instance from the given source.

fill(value: number, offset?: number, end?: number): void: Sets the given value to all bytes in this PolymorphicBuffer instance.

readUInt32BE(offset: number): number: Reads an unsigned 32-bit integer from this PolymorphicBuffer instance at the given offset.

writeUInt32BE(value: number, offset: number): void: Writes an unsigned 32-bit integer to this PolymorphicBuffer instance at the given offset.

readUInt32LE(offset: number): number: Reads an unsigned 32-bit integer from this PolymorphicBuffer instance at the given offset.

writeUInt32LE(value: number, offset: number): void: Writes an unsigned 32-bit integer to this PolymorphicBuffer instance at the given offset.

readUInt8(offset: number): number: Reads an unsigned 8-bit integer from this PolymorphicBuffer instance at the given offset.

writeUInt8(value: number, offset: number): void: Writes an unsigned 8-bit integer to this PolymorphicBuffer instance at the given offset.

indexOf(subarray: PolymorphicBuffer | Uint8Array, offset?: number): number: Returns the index of the first occurrence of the given PolymorphicBuffer instance in this PolymorphicBuffer instance.

toString(encoding?: BufferEncoding): string: Returns a string representation of the PolymorphicBuffer instance.

License

THis module is licensed under the Affero General Public License v3.0. See the LICENSE file for more information.