
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
node-ts-uuid
Advanced tools
A simple uuid generator. The generator uses the MAC address / IPv6 address + the process id + the current time to ensure a unique id is generated. The length of the uuid can be specified, this will either increase or decrease the number of characters in the uuid. If the uuid needs to be padded to create a longer uuid, a bitwise operation is used to generate the unique characters. A prefix may also specified.
yarn add node-ts-uuid
import { Uuid, UuidOptions } from 'node-ts-uuid';
const options: UuidOptions = {
length: 50,
prefix: 'test-',
};
export function getUuid() {
const uuid: string = Uuid.generate(options);
console.log(uuid);
return uuid;
}
Will generate a uuid similar to: test-6xke0ccwg0k00emrjrz81gu8a63657918908addf9942c
generate(options?: UuidOptions)
Generates a UUID using the IPv6 / Mac Address, the process id, and the current time. Optionally add a prefix, and limit / pad the uuid to be a specific length.
getPid()
Returns the running process id or a randomly generated 5 digit number.
getAddress()
Returns the MAC Address or IPv6 Address, if neither are available a randomly generated 8 digit number is returned.
getNow()
Returns the current epoch time or the previously returned epoch time incremented by 1.
postProcessUuid(uuid: string, length?: number)
Pads / limits the length of the provided uuid if the length is shorter than desired a bitwise operation provides the randomly generated characters.
UuidOptions {
length?: number;
prefix?: string;
}
length
: Pad / Limit the length of the uuid.prefix
: Add a prefix to the uuid.MIT License
Contributions are encouraged, please see further details below:
Here are some basic rules to follow to ensure timely addition of your request:
main
branch. Any other branch (unless specified by the
maintainers) will get rejected.FAQs
A simple uuid generator
The npm package node-ts-uuid receives a total of 6,971 weekly downloads. As such, node-ts-uuid popularity was classified as popular.
We found that node-ts-uuid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.