Non Programming Manager

    node-unique

    1.1.0 • Public • Published

    unique

    Unique generates IDs, that is all. The IDs that are generated have the following properties.

    • Portable - Unique generates String IDs so they can be used anywhere.
    • Compact - Unique Base64 encodes IDs to minimize wasted space.
    • Timely - Unique includes a timestamp to the millisecond in its IDs.
    • Orderly - Unique IDs are lexicographically ordered by time.
    • Random - Unique includes 122 random bits in its IDs.

    Definition: base64(bin(hex(now()) + uuidV4()))

    Where:

    • now() returns an integer representing milliseconds since epoch
    • uuidV4() returns a 32 character hex string (no dashes)

    API

    unique([ts]) - Generates a new id.

    ts: Date (Optional)

    • Description: A date representing the timestamp you want encoded into your ID.
    • Default: Now.

    unique.getTimestamp(id) - Returns the timestamp encoded in the given id.

    id: String

    • Description: An id to extract the timestamp from.

    Keywords

    none

    Install

    npm i node-unique

    DownloadsWeekly Downloads

    94

    Version

    1.1.0

    License

    ISC

    Last publish

    Collaborators

    • tleef