MCPcopy
hub / github.com/uuidjs/uuid / v7

Function v7

src/v7.ts:22–49  ·  view source on GitHub ↗
(
  options?: Version7Options,
  buf?: TBuf,
  offset?: number,
)

Source from the content-addressed store, hash-verified

20 offset?: number,
21): TBuf;
22function v7<TBuf extends Uint8Array = Uint8Array>(
23 options?: Version7Options,
24 buf?: TBuf,
25 offset?: number,
26): UUIDTypes<TBuf> {
27 let bytes: Uint8Array;
28
29 if (options) {
30 // With options: Make UUID independent of internal state
31 bytes = v7Bytes(
32 options.random ?? options.rng?.() ?? rng(),
33 options.msecs,
34 options.seq,
35 buf,
36 offset,
37 );
38 } else {
39 // No options: Use internal state
40 const now = Date.now();
41 const rnds = rng();
42
43 updateV7State(_state, now, rnds);
44
45 bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
46 }
47
48 return buf ?? unsafeStringify(bytes);
49}
50
51// (Private!) Do not use. This method is only exported for testing purposes
52// and may change without notice.

Callers 2

uuid-bin.tsFile · 0.70
v7.test.tsFile · 0.50

Calls 4

v7BytesFunction · 0.85
updateV7StateFunction · 0.85
unsafeStringifyFunction · 0.85
rngFunction · 0.70

Tested by

no test coverage detected