multiarray-ts

0.1.0 • Public • Published

MultiArray-ts

A Zig inspired TypeScript project to create a compact MultiArray and retrieve elements by index.

import {type MultiArray, getIndex, removeObjectAtIndex, replaceObjectAtIndex, addObject} from 'multiarray-ts';

type Example = { id: number; name: string; age: number };
const data: MultiArray<Example> = {
  id: [1, 2, 3],
  name: ["Alice", "Bob", "Charlie"],
  age: [25, 30, 35],
};

// Fetch
const proxy = getIndex(data, 1);
console.log(proxy.name); // Bob

// Add
addObject(data, {id: 5, name: "Eve", age: 22});

// Remove
removeObjectAtIndex(data, 1);

// Replace
replaceObjectAtIndex(data, {id: 4, name: "David", age: 40}, 0);

/multiarray-ts/

    Package Sidebar

    Install

    npm i multiarray-ts

    Weekly Downloads

    0

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    5.09 kB

    Total Files

    5

    Last publish

    Collaborators

    • jadbox