Socket
Socket
Sign inDemoInstall

typeid-js

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeid-js - npm Package Compare versions

Comparing version 0.0.0-dev to 0.0.1

dist/base32.d.ts

24

package.json
{
"name": "typeid-js",
"version": "0.0.0-dev",
"version": "0.0.1",
"description": "Official implementation of the TypeID specification in TypeScript. TypeIDs are type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs",
"keywords": [
"typeid",
"uuid",
"uuidv7",
"guid"
],
"homepage": "https://github.com/jetpack-io/typeid-js",
"bugs": "https://github.com/jetpack-io/typeid-js/issues",
"license": "Apache-2.0",
"author": {
"name": "jetpack.io",
"email": "opensource@jetpack.io"
},
"repository": "github:jetpack-io/typeid-js",
"sideEffects": false,

@@ -8,2 +23,9 @@ "main": "./dist/index.js",

"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"files": [

@@ -10,0 +32,0 @@ "dist/**"

45

README.md

@@ -1,7 +0,4 @@

# TypeID TS
### Official JavaScript implementation of [TypeIDs](https://github.com/jetpack-io/typeid) using TypeScript.
# Official TypeID-JS Package
### JavaScript implementation of [TypeIDs](https://github.com/jetpack-io/typeid) using TypeScript.
This is the official TypeScript package for TypeIDs written by jetpack.io (authors of the
original TypeID spec).
TypeIDs are a modern, **type-safe**, globally unique identifier based on the upcoming

@@ -12,10 +9,28 @@ UUIDv7 standard. They provide a ton of nice properties that make them a great choice

This particular implementation provides an npm package that can be used by any JavaScript
or TypeScript project.
This is the official JavaScript / TypeScript implementation of TypeID by the
[jetpack.io](https://jetpack.io) team. It provides an npm package that can be used by
any JavaScript or TypeScript project.
# Library Usage
# Installation
Using npm:
```bash
npm install typeid-js
```
Using yarn:
```bash
yarn add typeid-js
```
Using pnpm:
```bash
pnpm add typeid-js
```
# Usage
To create a random TypeID of a given type, use the `typeid()` function:
```typescript
import { typeid } from 'typeid-ts';
import { typeid } from 'typeid-js';
const tid = typeid("prefix");

@@ -28,3 +43,3 @@ ```

```typescript
import { typeid } from 'typeid-ts';
import { typeid } from 'typeid-js';
const tid = typeid();

@@ -38,3 +53,3 @@ ```

```typescript
import { TypeID } from 'typeid-ts';
import { TypeID } from 'typeid-js';

@@ -46,3 +61,3 @@ const tid = TypeID.fromString("prefix_00041061050r3gg28a1c60t3gf);

```typescript
import { TypeID } from 'typeid-ts';
import { TypeID } from 'typeid-js';

@@ -56,6 +71,6 @@ const tid = TypeID.fromUUID("prefix", "00000000-0000-0000-0000-000000000000");

+ `toString()`: Encodes the object as a string, using the canonical format
+ `asUUID()`: Decodes the TypeID into a UUID string in hex format. The type prefix is ignored
+ `asUUIDBytes()`: Decodes the TypeID into a UUID byte array. The type prefix is ignored
+ `toUUID()`: Decodes the TypeID into a UUID string in hex format. The type prefix is ignored
+ `toUUIDBytes()`: Decodes the TypeID into a UUID byte array. The type prefix is ignored
+ `fromString(str)`: Parses a TypeID from a string
+ `fromUUID(prefix, uuid)`: Creates a TypeID from a prefix and a UUID in hex format
+ `fromUUIDBytes(prefix, bytes)`: Creates a TypeID from a prefix and a UUID in byte array format
+ `fromUUIDBytes(prefix, bytes)`: Creates a TypeID from a prefix and a UUID in byte array format
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc