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

Function decodeLine

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

Source from the content-addressed store, hash-verified

240}
241
242export function decodeLine(value: string): Line {
243 const equationConsts = value.substring(1, value.length - 1).split(",") as [
244 Float8,
245 Float8,
246 Float8,
247 ];
248
249 if (equationConsts.length !== 3) {
250 throw new Error(
251 `Invalid Line: "${value}". Line in linear equation format must have 3 constants, ${equationConsts.length} given.`,
252 );
253 }
254
255 for (const c of equationConsts) {
256 if (Number.isNaN(parseFloat(c))) {
257 throw new Error(
258 `Invalid Line: "${value}". Line constant "${c}" must be a valid number.`,
259 );
260 }
261 }
262
263 const [a, b, c] = equationConsts;
264
265 return {
266 a: a,
267 b: b,
268 c: c,
269 };
270}
271
272export function decodeLineArray(value: string) {
273 return parseArray(value, decodeLine);

Callers 2

decodeTextFunction · 0.90
decode_test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected