1.0.7 • Published 2 months ago

mainid v1.0.7

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

IdGenerator

IdGenerator

1) Features; 2) Usage: 1) Prepare: 1) Create id generator: 1) Unsafe; 2) Safe; 3) Dictionary and random pool size. 2) Commands: 1) Create.

Features

1) Unlimited id size; 2) Configurable random pool size; 3) Replacable dictionary; 4) Support replacable Crypto (requires Buffer); 5) Fallback to Math.random (if Crypto & Buffer not used).

Usage

Prepare

import { IdGenerator } 'mainid';

Create id generator

Unsafe

Math.random for random

const idGenerator = new IdGenerator();
Safe
  • Crypto - usage: crypto.getRandomValues(buffer);
  • Buffer is required - usage: buffer = buffer.alloc(randomPoolSize).
const idGenerator = new IdGenerator({
  crypto: /** @type {Crypto} */ (crypto)
});
Dictionary and random pool size

Optinal.

const idGenerator = new IdGenerator({
  dictionary: 'abc',
  randomPoolSize: 3
});

Commands

1) Create;

Create

const id = idGenerator.create();
1.0.7

2 months ago

1.0.6

2 months ago

1.0.5

2 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago