@chronark/prefixed-id
Advanced tools
Comparing version 0.3.8 to 0.4.0
{ | ||
"name": "@chronark/prefixed-id", | ||
"version": "0.3.8", | ||
"main": "./src/index.js", | ||
"typings": "./src/index.d.ts", | ||
"dependencies": { | ||
"base-x": "^3.0.9" | ||
"version": "0.4.0", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [], | ||
"author": "Andreas Thomas", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/node": "^18.8.5", | ||
"rome": "^11.0.0", | ||
"tsup": "^6.2.3", | ||
"tsx": "^3.10.1", | ||
"typescript": "^4.8.4" | ||
}, | ||
"peerDependencies": {} | ||
} | ||
"scripts": { | ||
"test": "node --loader=tsx --test ./**/*.test.ts ", | ||
"build": "tsup", | ||
"fmt": "rome check . --apply-suggested && rome format . --write" | ||
} | ||
} |
@@ -1,21 +0,55 @@ | ||
# prefixed-id | ||
<div align="center"> | ||
<h1 align="center">@chronark/prefixed-id</h1> | ||
<h5>pre_JUbF9zRGz9hrFXUyNJLXcowD9GsqCD</h5> | ||
</div> | ||
Easy way to generate prefixed unique ids similar to what stripe does. | ||
Based on uuid v4. | ||
<br/> | ||
This is just a typesafe convenient wrapper for generating prefixed ids. | ||
A minimal library to generate Stripe inspired predixed ids for your application. | ||
# Usage | ||
Works in | ||
- Nodejs | ||
- Cloudflare Workers | ||
- Vercel Edge | ||
```typescript | ||
import { IdGenerator } from '@chronark/prefixed-id'; | ||
## Install | ||
``` | ||
npm i @chronark/prefixed-id | ||
``` | ||
## Usage | ||
### Nodejs | ||
```ts | ||
import nodeCrypto from "node:crypto" | ||
const idGenerator = new IdGenerator({ | ||
humanReadableName: 'prefix', | ||
// Example: | ||
user: 'u', | ||
}); | ||
prefixes: { | ||
"user": "u", | ||
}, | ||
crypto: nodeCrypto | ||
}) | ||
idGenerator.id('user'); | ||
// -> u_xxxxxxxxxxxxxxxxxx... | ||
console.log(idGenerator.id("user")) | ||
// u_PtbBA7NGcYYDpae6ULWujk | ||
``` | ||
### WebCrypto | ||
- Cloudflare Workers | ||
- Vercel Edge | ||
```ts | ||
const idGenerator = new IdGenerator({ | ||
prefixes: { | ||
"user": "u", | ||
}, | ||
crypto: crypto // will be globally defined | ||
}) | ||
console.log(idGenerator.id("user")) | ||
// u_PtbBA7NGcYYDpae6ULWujk | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
24740
0
290
1
56
5
8
1
- Removedbase-x@^3.0.9
- Removedbase-x@3.0.10(transitive)
- Removedsafe-buffer@5.2.1(transitive)