Skip to content

Latest commit

 

History

History
49 lines (43 loc) · 1.16 KB

README.md

File metadata and controls

49 lines (43 loc) · 1.16 KB

ArrayDatabase

A database manager for storing unlimited array in ScriptAPI
Compatible with @minecraft/[email protected]+

Usage

JavaScript

/** @type {ArrayDatabase<string>} */
const db = new ArrayDatabase('test');

db.add('hello');
db.add('world');
db.getAll(); // ["hello", "world"]
db.has('hello'); // true
db.clear();
db.size; // 0

TypeScript

const db = new ArrayDatabase<Vector3>('test');

db.add({ x: 0, y: 0, z: 0 });
db.add({ x: 1, y: 1, z: 1 });
db.getAll(); // [{ x: 0, y: 0, z: 0 }, { x: 1, y: 1, z: 1 }]

Method/Properties

  • (template) T
  • readonly id: string
  • get size(): number
  • getAll(): T[]
  • add(value: T): this
  • has(value: T): boolean
  • clear(): void
  • *values(): IterableIterator<T>
  • find(callbackfn: (value: T) => boolean): T | undefined
  • filter(callbackfn: (value: T) => boolean): T[]
  • map<U>(callbackfn: (value: T) => U): U[]
  • forEach(callbackfn: (value: T) => void): void
  • some(callbackfn: (value: T) => boolean): boolean
  • every(callbackfn: (value: T) => boolean): boolean
  • [Symbol.iterator](): IterableIterator<T>

Benchmark (put)

x10 x100
string(100bytes) 0ms 6ms
vector3 1ms 34ms