MCPcopy
hub / github.com/langchain-ai/langchainjs / parse

Function parse

libs/langchain-core/src/utils/uuid/parse.ts:4–37  ·  view source on GitHub ↗
(uuid: string)

Source from the content-addressed store, hash-verified

2import validate from "./validate.js";
3
4function parse(uuid: string): NonSharedArrayBuffer {
5 if (!validate(uuid)) {
6 throw TypeError("Invalid UUID");
7 }
8
9 let v: number;
10 return Uint8Array.of(
11 (v = parseInt(uuid.slice(0, 8), 16)) >>> 24,
12 (v >>> 16) & 0xff,
13 (v >>> 8) & 0xff,
14 v & 0xff,
15
16 // Parse ........-####-....-....-............
17 (v = parseInt(uuid.slice(9, 13), 16)) >>> 8,
18 v & 0xff,
19
20 // Parse ........-....-####-....-............
21 (v = parseInt(uuid.slice(14, 18), 16)) >>> 8,
22 v & 0xff,
23
24 // Parse ........-....-....-####-............
25 (v = parseInt(uuid.slice(19, 23), 16)) >>> 8,
26 v & 0xff,
27
28 // Parse ........-....-....-....-############
29 // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
30 ((v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000) & 0xff,
31 (v / 0x100000000) & 0xff,
32 (v >>> 24) & 0xff,
33 (v >>> 16) & 0xff,
34 (v >>> 8) & 0xff,
35 v & 0xff
36 );
37}
38
39export default parse;

Callers 6

interopSafeParseFunction · 0.90
interopParseFunction · 0.90
v1ToV6Function · 0.70
v35Function · 0.70
parseConfigFunction · 0.50

Calls 1

validateFunction · 0.70

Tested by

no test coverage detected