
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
use-tiny-id
Advanced tools
View on npmjs - View on github
use-tiny-id
is an npm package designed to quickly create incremental IDs, so that all IDs are unique. You can run test.js
to get an idea of the performance, which is similar to nanoid for generating a 21 character id.
Install
npm install use-tiny-id
Use
const Generator = require('use-tiny-id');
const myGenerator = new Generator();
console.log(myGenerator.next());// a
new Generator(characters, options)
// creates a simple id generator
const myGenerator = new Generator();
// creates a generator with a custom alphabet
const myGenerator = new Generator('abcd');
// creates a generator with a custom alphabet and a config
const myGenerator = new Generator('abcd', {
numberOfCharacters: 10,
lastGeneratedId: 'aaaaaaaaac'
});
// creates a generator with a simple config
const myGenerator = new Generator();
myGenerator.config({
numberOfCharacters: 10,
lastGeneratedId: 'aaaaaaaaac'
});
Type definition
type UniqueIdGeneratorOptions = {
numberOfCharacters?: number;
lastGeneratedId?: string;
};
Changes the generator's configuration
myGenerator.config({
numberOfCharacters: 10,
lastGeneratedId: 'aaaaaaaaac'
});
Type definition
type UniqueIdGeneratorOptions = {
numberOfCharacters?: number;
lastGeneratedId?: string;
};
Returns the number of generated ids
const count: number = myGenerator.count();
Increments the id. It returns the generators instance, so you can chain many calls.
myGenerator.increment();
myGenerator
.increment()
.increment();
Returns the current id and increment it
const id: string = myGenerator.next();
Returns the current id without incrementing it
const id: string = myGenerator.current();
The characters used to generate the ids.
// 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' by default
console.log(myGenerator.chars);
An array of numbers, which is the current state of the id generator.
// [0, ...]
console.log(myGenerator.status);
FAQs
Generate incremental ids easily and quickly
We found that use-tiny-id demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.