Skip to content

A TypeScript library to create a compact Zig-inspired MultiArrayList and retrieve elements by index

Notifications You must be signed in to change notification settings

jadbox/multiarray-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

A TypeScript library to create a compact Zig-inspired MultiArrayList and retrieve elements by index

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published