rid.js

A lightweight package to generate IDs.

Usage no npm install needed!

<script type="module">
  import ridJs from 'https://cdn.skypack.dev/rid.js';
</script>

README

Table Of Contents

About

Examples

Types

Classes

About

rid.js is a lightweight package that allows you to generate IDs. The IDs can be any length (as long as it's not 0).

It's simple to use, and new features are being added!

Examples

Generator:

const { Generator } = require('rid.js');
const generator = new Generator();

const id = generator.gen("all", 10); //"all" is the type of ID.
//10 is the length of the ID.
console.log(id);
//Output: P?i*OY74&C
//Output will be different for you.

Interval generator

const { Interval } = require('rid.js');

const generator = new Interval();

generator.gen("all", 10, 3000) //3000 is the amount of milliseconds between each generation.

//Output:
// hqpftljmcn
// ctleoanlpc
// gvmsdbkvyf
// yajsuybbos
// qitvnhcfoh
// owmmuctrdm
// mjxlcgaztz
// lrvriqmgzd
// hwqblmzhkw


//Each one of the IDs are generated with 3000 milliseconds between.

Types

Type Description
"all" Generates an ID with letters, numbers, and symbols.
"letter" Generates an ID with only letters.
"letterAndSymbol" Generates an ID with just letters and symbols.
"number" Generates an ID with only numbers.
"numberAndLetter" Generates an ID with just numbers and letters.
"numberAndSymbol" Generates an ID with just numbers and symbols.
"symbol" Generates an ID with only symbols.

Classes

Generator:

Generates a random ID with a type and a length.

Interval:

Generates a random ID every x milliseconds provided.