
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
UUID Wand is a TypeScript library that provides functionality to generate and validate UUIDs (Universally Unique Identifiers).
To use this library in your project, make sure you have Node.js installed. Follow the steps below to install and use the library:
Clone the repository or download the source code files.
Install the required dependencies by running the following command in the project directory:
npm install uuid-wand
yarn add uuid-wand
pnpm add uuid-wand
Import the UuidGenerator
class into your TypeScript file:
import UuidGenerator from 'uuid-wand';
The UuidGenerator
class provides four methods for generating UUIDs:
v1()
: Generates a version 1 UUID using the current timestamp, clock sequence, and node ID.
const uuidV1 = UuidGenerator.v1();
console.log(uuidV1); // Output: e.g., '6a365c44-e127-11eb-b95f-cb258f9664de'
v3(namespace: string, name: string)
: Generates a version 3 UUID using the provided namespace and name.
const uuidV3 = UuidGenerator.v3(
'6ba7b810-9dad-11d1-80b4-00c04fd430c8',
'Hello, World!',
);
console.log(uuidV3); // Output: e.g., '2ed6657d-e927-568b-95e1-2665a8aea6a2'
v4()
: Generates a version 4 UUID using random values.
const uuidV4 = UuidGenerator.v4();
console.log(uuidV4); // Output: e.g., 'd6e3c7b6-8e47-4a3c-a31c-78168d0b96cd'
v5(namespace: string, name: string)
: Generates a version 5 UUID using the provided namespace and name.
const uuidV5 = UuidGenerator.v5(
'6ba7b811-9dad-11d1-80b4-00c04fd430c8',
'Hello, World!',
);
console.log(uuidV5); // Output: e.g., '886313e1-3b8a-5372-9b90-0c9aee199e5d'
validate()
method can be used to check if a given string is a valid UUID.const uuid = '6a365c44-e127-11eb-b95f-cb258f9664de';
const isValid = UuidGenerator.validate(uuid);
console.log(isValid); // Output: true
const uuids = UuidGenerator.bulkGenerateV4(5);
console.log(uuids);
// Output:
// [
// 'd6e3c7h6-8e47-4a3c-a31c-78168d0b96jd',
// 'd6e3c7b6-8h47-4a3c-a31c-78168d0b96ca',
// 'd6e3c7b6-8347-4g3c-a31c-78168d0b96cq',
// 'd6e3c7b6-8e47-4d3c-a31c-78168d0b96cj',
// 'd6e3c7b6-8e47-4a3c-b31c-78168d0b96cl'
const uuid = '6a365c44-e127-11eb-b95f-cb258f9664de';
const timestamp = UuidGenerator.extractTimestampV1(uuid);
console.log(timestamp); // Output: 1625765020000
const shortUuid = UuidGenerator.shortUuid();
console.log(shortUuid); // Output: '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
This library is released under the MIT License. Feel free to modify and use it in your projects.
FAQs
A UUID generator library for TypeScript
The npm package uuid-wand receives a total of 55 weekly downloads. As such, uuid-wand popularity was classified as not popular.
We found that uuid-wand 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.