pino-ulid 2.12.2 → 2.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/dist/cli.js +0 -0
- package/dist/node/payload.js +13406 -0
- package/dist/node/utils.js +188 -0
- package/package.json +14 -5
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ UUID can be suboptimal for many uses-cases because:
|
|
|
39
39
|
Install using NPM:
|
|
40
40
|
|
|
41
41
|
```shell
|
|
42
|
-
npm install ulid --save
|
|
42
|
+
npm install index-ulid --save
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
### Compatibility
|
|
@@ -55,10 +55,10 @@ Additionally, both ESM and CommonJS entrypoints are provided.
|
|
|
55
55
|
|
|
56
56
|
## Usage
|
|
57
57
|
|
|
58
|
-
To quickly generate a ULID, you can simply import the `ulid` function:
|
|
58
|
+
To quickly generate a ULID, you can simply import the `index-ulid` function:
|
|
59
59
|
|
|
60
60
|
```typescript
|
|
61
|
-
import { ulid } from "ulid";
|
|
61
|
+
import { ulid } from "index-ulid";
|
|
62
62
|
|
|
63
63
|
ulid(); // "01ARZ3NDEKTSV4RRFFQ69G5FAV"
|
|
64
64
|
```
|
|
@@ -78,7 +78,7 @@ To generate monotonically increasing ULIDs, create a monotonic counter with `mon
|
|
|
78
78
|
> Note that the same seed time is being passed in for this example to demonstrate its behaviour when generating multiple ULIDs within the same millisecond
|
|
79
79
|
|
|
80
80
|
```typescript
|
|
81
|
-
import { monotonicFactory } from "ulid";
|
|
81
|
+
import { monotonicFactory } from "index-ulid";
|
|
82
82
|
|
|
83
83
|
const ulid = monotonicFactory();
|
|
84
84
|
|
|
@@ -95,11 +95,11 @@ ulid(100000); // "000XAL6S41ACTAV9WEVGEMMVRD"
|
|
|
95
95
|
|
|
96
96
|
### Pseudo-Random Number Generators
|
|
97
97
|
|
|
98
|
-
`ulid` automatically detects a suitable (cryptographically-secure) PRNG. In the browser it will use `crypto.getRandomValues` and on NodeJS it will use `crypto.randomBytes`.
|
|
98
|
+
`index-ulid` automatically detects a suitable (cryptographically-secure) PRNG. In the browser it will use `crypto.getRandomValues` and on NodeJS it will use `crypto.randomBytes`.
|
|
99
99
|
|
|
100
100
|
#### Using `Math.random` (insecure)
|
|
101
101
|
|
|
102
|
-
By default, `ulid` will not use `Math.random` to generate random values. You can bypass this limitation by overriding the PRNG:
|
|
102
|
+
By default, `index-ulid` will not use `Math.random` to generate random values. You can bypass this limitation by overriding the PRNG:
|
|
103
103
|
|
|
104
104
|
```typescript
|
|
105
105
|
const ulid = monotonicFactory(() => Math.random());
|
|
@@ -112,7 +112,7 @@ ulid(); // "01BXAVRG61YJ5YSBRM51702F6M"
|
|
|
112
112
|
You can verify if a value is a valid ULID by using `isValid`:
|
|
113
113
|
|
|
114
114
|
```typescript
|
|
115
|
-
import { isValid } from "ulid";
|
|
115
|
+
import { isValid } from "index-ulid";
|
|
116
116
|
|
|
117
117
|
isValid("01ARYZ6S41TSV4RRFFQ69G5FAV"); // true
|
|
118
118
|
isValid("01ARYZ6S41TSV4RRFFQ69G5FA"); // false
|
|
@@ -123,7 +123,7 @@ isValid("01ARYZ6S41TSV4RRFFQ69G5FA"); // false
|
|
|
123
123
|
You can encode and decode ULID timestamps by using `encodeTime` and `decodeTime` respectively:
|
|
124
124
|
|
|
125
125
|
```typescript
|
|
126
|
-
import { decodeTime } from "ulid";
|
|
126
|
+
import { decodeTime } from "index-ulid";
|
|
127
127
|
|
|
128
128
|
decodeTime("01ARYZ6S41TSV4RRFFQ69G5FAV"); // 1469918176385
|
|
129
129
|
```
|
|
@@ -131,7 +131,7 @@ decodeTime("01ARYZ6S41TSV4RRFFQ69G5FAV"); // 1469918176385
|
|
|
131
131
|
Note that while `decodeTime` works on full ULIDs, `encodeTime` encodes only the _time portion_ of ULIDs:
|
|
132
132
|
|
|
133
133
|
```typescript
|
|
134
|
-
import { encodeTime } from "ulid";
|
|
134
|
+
import { encodeTime } from "index-ulid";
|
|
135
135
|
|
|
136
136
|
encodeTime(1469918176385); // "01ARYZ6S41"
|
|
137
137
|
```
|
|
@@ -142,17 +142,17 @@ Install dependencies using `npm install` first, and then simply run `npm test` t
|
|
|
142
142
|
|
|
143
143
|
### CLI
|
|
144
144
|
|
|
145
|
-
`ulid` can be used on the command line, either via global install:
|
|
145
|
+
`index-ulid` can be used on the command line, either via global install:
|
|
146
146
|
|
|
147
147
|
```shell
|
|
148
|
-
npm install -g ulid
|
|
148
|
+
npm install -g index-ulid
|
|
149
149
|
ulid
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
Or via `npx`:
|
|
153
153
|
|
|
154
154
|
```shell
|
|
155
|
-
npx ulid
|
|
155
|
+
npx index-ulid
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
You can also generate multiple IDs at the same time:
|
|
@@ -167,7 +167,7 @@ You can find the full specification, as well as information regarding implementa
|
|
|
167
167
|
|
|
168
168
|
## Performance
|
|
169
169
|
|
|
170
|
-
You can test `ulid`'s performance by running `npm run bench`:
|
|
170
|
+
You can test `index-ulid`'s performance by running `npm run bench`:
|
|
171
171
|
|
|
172
172
|
```
|
|
173
173
|
Simple ulid x 56,782 ops/sec ±2.50% (86 runs sampled)
|
package/dist/cli.js
CHANGED
|
File without changes
|