Newton's Preposterous Miscalculation

    @tofandel/uuid-base62

    1.1.1 • Public • Published

    npm version Build Dependency Status

    uuid-base62

    Base62 UUID encoder/decoder/generator (RFC4122 compliant)

    This is an up to date fork of dmarcelino/uuid-base62

    Original author Dario Marcelino dario@appscot.com

    Overview

    uuid-base62 makes it easy to generate short base62 (or any other base) UUIDs. The unencoded UUIDs are generated by uuid which follows RFC4122. The encoded UUIDs are alphanumeric [0-9a-zA-Z] and always have a length of 22 chars.

    Instalation

    npm i @tofandel/uuid-base62 -S

    Usage

    var uuidBase62 = require('@tofandel/uuid-base62');
    
    var uuid = uuidBase62.v4(); //You can use any uuid method (v1, v3, v4, v5) in accordance to their doc and a base62 encoded uuid will be returned
    // -> 2qY9COoAhfMrsH7mCyh86T
    
    // if the original uuid is needed
    var originalUuid = uuidBase62.decode(uuid);
    // -> 9af099b2-6244-4fc1-b72b-1d69a24481b7
    
    // if an uuid needs to be encoded
    var encoded = uuidBase62.encode('8fc60e7c-3b3c-48e9-a6a7-a5fe4f1fbc31');
    // -> 2fNwVYePN8WqqDFvVf7XMN

    That's it. uuid-base62 also supports other bases, example for base64:

    uuidBase62.customBase = new uuidBase62.baseX("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_");
    var uuid = uuidBase62.v4();
    // -> 31LoSI_BVeQpXtwu_-GEbL

    For more examples check the tests.

    License

    MIT

    Install

    npm i @tofandel/uuid-base62

    DownloadsWeekly Downloads

    576

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    12.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • tofandel