MCPcopy Create free account
hub / github.com/denodrivers/postgres / decodeBox

Function decodeBox

query/decoders.ts:49–70  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

47}
48
49export function decodeBox(value: string): Box {
50 const points = value.match(/\(.*?\)/g) || [];
51
52 if (points.length !== 2) {
53 throw new Error(
54 `Invalid Box: "${value}". Box must have only 2 point, ${points.length} given.`,
55 );
56 }
57
58 const [a, b] = points;
59
60 try {
61 return {
62 a: decodePoint(a),
63 b: decodePoint(b),
64 };
65 } catch (e) {
66 throw new Error(
67 `Invalid Box: "${value}" : ${(e instanceof Error ? e.message : e)}`,
68 );
69 }
70}
71
72export function decodeBoxArray(value: string) {
73 return parseArray(value, decodeBox, ";");

Callers 2

decodeTextFunction · 0.90
decode_test.tsFile · 0.90

Calls 1

decodePointFunction · 0.85

Tested by

no test coverage detected