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.7.0 to 1.0.0

2

dist/index.d.ts

@@ -11,3 +11,3 @@ declare class TypeID<const T extends string> {

toString(): `${T}_${string}` | string;
static fromString<const T extends string>(str: string): TypeID<T>;
static fromString<const T extends string>(str: string, prefix?: T): TypeID<T>;
static fromUUIDBytes<const T extends string>(prefix: T, bytes: Uint8Array): TypeID<T>;

@@ -14,0 +14,0 @@ static fromUUID<const T extends string>(prefix: T, uuid: string): TypeID<T>;

@@ -771,2 +771,5 @@ "use strict";

}
if (!s) {
throw new Error(`Invalid TypeId. Suffix cannot be empty`);
}
if (prefix && p !== prefix) {

@@ -850,4 +853,4 @@ throw new Error(

}
static fromString(str) {
const typeIdRaw = fromString(str);
static fromString(str, prefix) {
const typeIdRaw = fromString(str, prefix);
return new TypeID(getType(typeIdRaw), getSuffix(typeIdRaw));

@@ -854,0 +857,0 @@ }

{
"name": "typeid-js",
"version": "0.7.0",
"version": "1.0.0",
"description": "Official implementation of the TypeID specification in TypeScript. TypeIDs are type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs",

@@ -54,2 +54,2 @@ "keywords": [

}
}
}
# Official TypeID-JS Package
![License: Apache 2.0](https://img.shields.io/github/license/jetify-com/typeid) [![Built with Devbox](https://www.jetify.com/img/devbox/shield_galaxy.svg)](https://www.jetify.com/devbox)

@@ -77,7 +78,5 @@ ### JavaScript implementation of [TypeIDs](https://github.com/jetify-com/typeid) using TypeScript.

// The asType() call is optional, but it converts to type TypeID<"prefix"> instead
// of TypeID<string>
const tid = TypeID.fromString('prefix_00041061050r3gg28a1c60t3gf').asType(
'prefix'
);
// The prefix is optional, but it enforces the prefix and returns a
// TypeID<"prefix"> instead of TypeID<string>
const tid = TypeID.fromString('prefix_00041061050r3gg28a1c60t3gf', 'prefix');
```

@@ -101,4 +100,4 @@

- `toUUIDBytes()`: Decodes the TypeID into a UUID byte array. The type prefix is ignored
- `fromString(str)`: Parses a TypeID from a string
- `fromString(str, prefix?)`: Parses a TypeID from a string, optionally checking the prefix
- `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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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