Code Monkey home page Code Monkey logo

simple-uuid's Introduction

simple-uuid

A simple uuid generator, in a AMD module.

Install

jam install simple-uuid
define('app/ui', ['simple-uuid'], function(uuid) {
    uuid.uuid();
})

Usage

uuid(length, radix)

  • length the desired number of characters
  • radix the number of allowable values for each character.

EXAMPLES:

No arguments - returns RFC4122, version 4 ID

uuid.uuid() // returns a string like "92329D39-6F5C-4520-ABFC-AAB64544E172"

One argument - returns ID of the specified length

uuid.uuid(15)     // 15 character ID (default base=62) "VcydxgltxrVZSTV"

Two arguments - returns ID of the specified length, and radix. (Radix must be <= 62)

uuid.uuid(8, 2)  // 8 character ID (base=2)  "01001010"
uuid.uuid(8, 10) // 8 character ID (base=10) "47473046"
uuid.uuid(8, 16) // 8 character ID (base=16) "098F4D35"

A more performant, but slightly bulkier, RFC4122v4 solution. We boost performance by minimizing calls to random()

uuid.uuidFast()

A more compact, but less performant, RFC4122v4 solution:

uuid.uuidCompact()

simple-uuid's People

Contributors

ryanramage avatar

Stargazers

 avatar Nelson Yee avatar

Watchers

 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.