0.0.4 • Published 4 years ago

autoincr v0.0.4

Weekly downloads
2
License
(Apache 2.0 OR MI...
Repository
github
Last release
4 years ago

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.