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.
- 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.
npm install plaxis
bun add plaxis
import ArrayList from 'plaxis';
const primitiveList = new ArrayList<number>({ dataType: 'i32' }); // Allocates memory for 32-bit signed integers
primitiveList.setData(0, 42);
console.log(primitiveList.getData(0)); // 42
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 }
bool
: Boolean (true
orfalse
)i8
,u8
: 8-bit signed and unsigned integersi16
,u16
: 16-bit signed and unsigned integersi32
,u32
: 32-bit signed and unsigned integersf32
,f64
: 32-bit and 64-bit floating point numbersbigi64
,bigu64
: 64-bit signed and unsigned BigInt numbers
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
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.
Gets the data stored at the specified index.
- index: The index of the data to retrieve.
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.
Manages the memory and storage for primitive data types.
Retrieves the data at the given index.
Stores the data at the specified index.
Manages memory for non-primitive (object) data types.
Retrieves the object at the given index.
Stores an object at the specified index.
This project is licensed under the MIT License. See the LICENSE file for details.