Socket
Book a DemoInstallSign in
Socket

@agoralabs-sh/uuid

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoralabs-sh/uuid

A UUID v4 utility package that allows generation and encoding/decoding.

1.1.0
latest
Source
npmnpm
Version published
Maintainers
2
Created
Source

License: CC0-1.0 NPM Version

GitHub Release GitHub Release

@agoralabs/uuid

A UUID v4 utility package that allows generation and encoding/decoding.

Table of Contents

🪄 1. Getting Started

1.1. Installation

You can install the types using:

npm add @agoralabs-sh/uuid

Back to top ^

1.2. API Reference

1.2.1. generate([options])

Generates a random UUID v4 string.

Parameters
NameTypeRequiredDefaultDescription
optionsIExtraOptionsno-Options that allows the UUID to to be returned to uppercase.
Returns
TypeDescription
stringA random UUID v4 string.
Example
import { generate } from '@agoralabs-sh/uuid';

const uuid = generate();

console.log(uuid);
// 18b0e62a-21c6-4e27-a813-825716f0fedb

Back to top ^

1.2.2. decode(value)

Decodes the UUID into a byte array. This removes any hyphens and case is preserved.

Parameters
NameTypeRequiredDefaultDescription
valuestringyes-The UUID to decode
Returns
TypeDescription
Uint8ArrayThe UUID as bytes.
Example
import { decode } from '@agoralabs-sh/uuid';

const decoded = decode('18b0e62a-21c6-4e27-a813-825716f0fedb');

console.log(decoded);
// [24, 176, 230, 42, 33, 198, 78, 39, 168, 19, 130, 87, 22, 240, 254, 219]

Back to top ^

1.2.3. encode(value, [options])

Encodes the UUID into the human-readable format with hyphens added.

Parameters
NameTypeRequiredDefaultDescription
valueUint8Arrayyes-A UUID byte array.
optionsIExtraOptionsno-Options that allows the UUID to to be returned to uppercase.
Returns
TypeDescription
stringThe encoded UUID string as a human-readable string.
Example
import { encode } from '@agoralabs-sh/uuid';

const uuid = encode(new Uint8Array([24, 176, 230, 42, 33, 198, 78, 39, 168, 19, 130, 87, 22, 240, 254, 219]));

console.log(uuid);
// 18b0e62a-21c6-4e27-a813-825716f0fedb

Back to top ^

1.2.4. IExtraOptions

NameTypeRequiredDefaultDescription
uppercasebooleannofalseWhether the UUID is transformed to uppercase.

Back to top ^

📑 2. Appendix

2.1. Useful Commands

CommandDescription
pnpm run buildGenerates build and TypeScript declaration files to the dist/ directory.
pnpm run cleanDeletes the dist/ directory and the tsconfig.*.tsbuildinfo files.
pnpm run generate:indexGenerates/overwrites the main index.ts file used for exporting all files.
pnpm run lintRuns the linter based on the rules in eslint.config.mjs.
pnpm run prettierRuns the prettier based on the rules in prettier.config.mjs.

Back to top ^

👏 3. How To Contribute

Please read the Contributing Guide to learn about the development process.

Back to top ^

📄 4. License

Please refer to the LICENSE file.

Back to top ^

🫶 5. Credits

  • The generation of the UUID is thanks to the amazing @dhest and their amazing @stablelib library.

Back to top ^

FAQs

Package last updated on 22 Feb 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.