bun-types 1.1.34-canary.20241029T141500 → 1.1.34-canary.20241031T140527
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/bun.d.ts +51 -0
- package/package.json +1 -1
package/bun.d.ts
CHANGED
|
@@ -5687,6 +5687,57 @@ declare module "bun" {
|
|
|
5687
5687
|
*/
|
|
5688
5688
|
match(str: string): boolean;
|
|
5689
5689
|
}
|
|
5690
|
+
|
|
5691
|
+
/**
|
|
5692
|
+
* Generate a UUIDv7, which is a sequential ID based on the current timestamp with a random component.
|
|
5693
|
+
*
|
|
5694
|
+
* When the same timestamp is used multiple times, a monotonically increasing
|
|
5695
|
+
* counter is appended to allow sorting. The final 8 bytes are
|
|
5696
|
+
* cryptographically random. When the timestamp changes, the counter resets to
|
|
5697
|
+
* a psuedo-random integer.
|
|
5698
|
+
*
|
|
5699
|
+
* @param encoding "hex" | "base64" | "base64url"
|
|
5700
|
+
* @param timestamp Unix timestamp in milliseconds, defaults to `Date.now()`
|
|
5701
|
+
*
|
|
5702
|
+
* @example
|
|
5703
|
+
* ```js
|
|
5704
|
+
* import { randomUUIDv7 } from "bun";
|
|
5705
|
+
* const array = [
|
|
5706
|
+
* randomUUIDv7(),
|
|
5707
|
+
* randomUUIDv7(),
|
|
5708
|
+
* randomUUIDv7(),
|
|
5709
|
+
* ]
|
|
5710
|
+
* [
|
|
5711
|
+
* "0192ce07-8c4f-7d66-afec-2482b5c9b03c",
|
|
5712
|
+
* "0192ce07-8c4f-7d67-805f-0f71581b5622",
|
|
5713
|
+
* "0192ce07-8c4f-7d68-8170-6816e4451a58"
|
|
5714
|
+
* ]
|
|
5715
|
+
* ```
|
|
5716
|
+
*/
|
|
5717
|
+
function randomUUIDv7(
|
|
5718
|
+
/**
|
|
5719
|
+
* @default "hex"
|
|
5720
|
+
*/
|
|
5721
|
+
encoding?: "hex" | "base64" | "base64url",
|
|
5722
|
+
/**
|
|
5723
|
+
* @default Date.now()
|
|
5724
|
+
*/
|
|
5725
|
+
timestamp?: number | Date,
|
|
5726
|
+
): string;
|
|
5727
|
+
|
|
5728
|
+
/**
|
|
5729
|
+
* Generate a UUIDv7 as a Buffer
|
|
5730
|
+
*
|
|
5731
|
+
* @param encoding "buffer"
|
|
5732
|
+
* @param timestamp Unix timestamp in milliseconds, defaults to `Date.now()`
|
|
5733
|
+
*/
|
|
5734
|
+
function randomUUIDv7(
|
|
5735
|
+
encoding: "buffer",
|
|
5736
|
+
/**
|
|
5737
|
+
* @default Date.now()
|
|
5738
|
+
*/
|
|
5739
|
+
timestamp?: number | Date,
|
|
5740
|
+
): Buffer;
|
|
5690
5741
|
}
|
|
5691
5742
|
|
|
5692
5743
|
// extends lib.dom.d.ts
|
package/package.json
CHANGED