Skip to content

zacharygolba/autoincr

Repository files navigation

autoincr

Use auto-incrementing values safely and effectively. Overflows are checked when you use a bounded number type (such as number) and there is optional support for the new unbounded bigint type.

Usage

import * as assert from "assert";
import autoincr from "autoincr";

const id = autoincr();

assert.eq(id.next(), 1);
assert.eq(id.next(), 2);
assert.eq(id.next(), 3);

id.reset();
assert.eq(id.next(), 1);

BigInt Support

The same API expressed in the example above can optionally return a bigint rather than a number by calling the .bigint method.

const id = autoincr.bigint();

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Auto-incrementing sequences with overflow checks.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published