@muds/genindex
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

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.

Package Sidebar

Install

npm i @muds/genindex

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

16.4 kB

Total Files

15

Last publish

Collaborators

  • andykswong