fast-id

    0.1.1 • Public • Published

    Fast-Id

    Quickly generate tens of millions of IDs (maximum 75200000), either sequentially or randomly.

    Installation

    npm install fast-id --save

    Usage

    Sequentially

    Sequentially generate ids from 1 to 100:

    const ID = require('fast-id')(100);
     
    const main = () => {
        let id;
     
        // Fetch the next id
        id = ID(); // 1
        console.log(id);
     
        // Fetch the next id
        id = ID(); // 2
        console.log(id);
    };
     
    main();

    Randomly

    Randomly generate ids from 1 to 100:

    const ID = require('fast-id')(100, {isRandom: true});
     
    const main = () => {
        let id;
     
        // Fetch the next id
        id = ID(); // a random id between 1 and 100
        console.log(id);
     
        // Fetch the next id
        id = ID(); // a random id between 1 and 100
        console.log(id);
    };
     
    main();

    Performance

    1. Sequentially

    Sequentially generating 10000000 ids takes less than 1 second.

    const max = 10000000;
    require('fast-id')(max, {logging: true});

    The result will be like below:

    fast-id initialized. [max = 10000000, 0.738s]
    

    2. Randomly

    Randomly generating 10000000 ids takes less than 1.5 seconds.

    const max = 10000000;
    require('fast-id')(max, {isRandom: true, logging: true});

    The result will be like below:

    fast-id initialized. [max = 10000000, 1.321s]
    

    License

    MIT

    Copyright (c) 2019, Owen Luke

    Keywords

    none

    Install

    npm i fast-id

    DownloadsWeekly Downloads

    0

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    5.68 kB

    Total Files

    10

    Last publish

    Collaborators

    • avatar