Memory-Safe Data Structures
npm install memsafeWORK IN PROGRESS
npm install memsafe
`
`html
// memsafe attached to window object
`usage
`js
import { MemSafeArray, MemSafeTable } from "memsafe";const array = new MemSafeArray();
array.push(1);
array.push({ key: "value" });
console.log(array.length);
// 2
for (const value of array) {
console.log(value);
}
// 1
// { key: "value" }
const table = new MemSafeTable({ column_names: ["id", "make", "model", "year"] });
table.push({ id: 123, make: "Chevrolet", model: "Malibu", "year": 2023 });
console.log(table.length);
// 1
for (const row of table) {
console.log(row)
}
// { id: 123, make: "Chevrolet", model: "Malibu", "year": 2023 }
table.drop_column("year");
for (const row of table) {
console.log(row)
}
// { id: 123, make: "Chevrolet", model: "Malibu" }
table.find(row => row.id === 123);
// { id: 123, make: "Chevrolet", model: "Malibu" }
``