Giter Site home page Giter Site logo

identifiers's Introduction

Identifiers

Generates unlimited, sequential, unique string identifiers.

This module makes it easy to keep track of things that need to be kept track of by some sort of unique identifier. It ensures that the identifiers generated will be unique and as small as possible with a reasonably limitless supply.

Identifiers are generated from a set of characters (by default: letters and numbers). Each next identifier is simply the next character in the sequence. After all single character identifiers have been exhausted, two character identifiers are used. Then three, then four, etc.

Installation

npm install identifiers

Usage

var Identifiers = require('identifiers'),
	identifiers = new Identifiers();

for (var i = 0; i < 5; i++)
	console.log(identifiers.next());

// logs:
//     a
//     b
//     c
//     d
//     e

Random Prefix

If identifiers should be difficult to guess, a random prefix can be added to each identifier by passing in a number specifying the length of the prefix when creating the identifiers instance.

var Identifiers = require('identifiers'),
	identifiers = new Identifiers(4);

for (var i = 0; i < 5; i++)
	console.log(identifiers.next());

// example output:
//     bscCa
//     cau5b
//     zavAc
//     x5qyd
//     UyTpe

Custom Character Set

A custom character set can be specified as the second argument when creating the identifiers instance.

var Identifiers = require('identifiers'),
	identifiers = new Identifiers(1, 'abc');

for (var i = 0; i < 5; i++)
	console.log(identifiers.next());

// example output:
//     ca
//     ab
//     cc
//     aaa
//     cab

identifiers's People

Contributors

nathan-wall avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.