0.2.0 • Published 2 months ago

@muds/genindex v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

genindex

license: MIT npm build

Overview

genindex is a simple library for generational index, which is a number encoded as index + generation value. It is mainly used as a weak reference to array values. The generation part allows indices to be reused without suffering from ABA problem, so that data can be safely stored in a packed array.

API Documentation

http://andykswong.github.io/muds

Usage

npm install --save genindex
import { IndexF64 } from 'genindex';

// create gen ID with index = 0 and generation = 0
const id = IndexF64.create(10);

// get index value
console.log(IndexF64.indexOf(id)); // 10

// increment generation
console.log(IndexF64.next(id)); // 4294967306

License

This repository and the code inside it is licensed under the MIT License. Read LICENSE for more information.

0.2.0

2 months ago