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

plaxis

v0.1.2

Published

`plaxis` is a powerful, type-safe array management library for JavaScript and TypeScript. It supports both primitive and non-primitive data types, offering efficient memory management through custom allocators.

Downloads

3

Readme

plaxis

plaxis is a powerful, type-safe array management library for JavaScript and TypeScript. It supports both primitive and non-primitive data types, offering efficient memory management through custom allocators.

Features

  • Primitive & Non-Primitive Data Handling: Supports all standard primitive data types (boolean, integers, floats, bigints) and complex non-primitive data types (objects).
  • Dynamic Array Capacity: Automatically expands storage to accommodate large data sets.
  • Memory-Efficient Allocators: Built-in allocators for both primitive and non-primitive data types, ensuring efficient memory usage and storage.
  • Type Safety: Generic class design that ensures type safety for stored data.

Installation Options

npm install plaxis
bun add plaxis

Usage

Importing

import ArrayList from 'plaxis';

Creating an ArrayList for Primitive Types

const primitiveList = new ArrayList<number>({ dataType: 'i32' }); // Allocates memory for 32-bit signed integers
primitiveList.setData(0, 42);
console.log(primitiveList.getData(0)); // 42

Creating an ArrayList for Non-Primitive Types

class MyObject {
  constructor(public name: string, public age: number) {}
}

const objectList = new ArrayList<MyObject>();
objectList.setData(0, new MyObject('Alice', 30));
console.log(objectList.getData(0)); // MyObject { name: 'Alice', age: 30 }

Supported Primitive Data Types

  • bool: Boolean (true or false)
  • i8, u8: 8-bit signed and unsigned integers
  • i16, u16: 16-bit signed and unsigned integers
  • i32, u32: 32-bit signed and unsigned integers
  • f32, f64: 32-bit and 64-bit floating point numbers
  • bigi64, bigu64: 64-bit signed and unsigned BigInt numbers

Dynamic Array Expansion

The library dynamically allocates memory as needed when adding data beyond the current capacity. For instance:

primitiveList.setData(1000, 12345); // Automatically expands the array capacity if needed

API Reference

ArrayList Class

constructor(config?: ArrayListConfig)

Creates a new ArrayList. Optionally, you can pass a configuration object.

  • config: ArrayListConfig
    • dataType: (Optional) Defines the data type (for primitive types) stored in the list.

getData(index: Index): T | null

Gets the data stored at the specified index.

  • index: The index of the data to retrieve.

setData(index: Index, item: T): void

Sets the data at the specified index.

  • index: The index at which the data should be stored.
  • item: The data to store at the index.

PrimitiveAllocator Class

Manages the memory and storage for primitive data types.

getData(index: Index): T | null

Retrieves the data at the given index.

setData(index: Index, item: T): void

Stores the data at the specified index.

NonPrimitiveAllocator Class

Manages memory for non-primitive (object) data types.

getData(index: Index): T | null

Retrieves the object at the given index.

setData(index: Index, item: T): void

Stores an object at the specified index.

License

This project is licensed under the MIT License. See the LICENSE file for details.