MCPcopy Create free account
hub / github.com/denoland/std / parseValue

Function parseValue

ini/parse.ts:69–77  ·  view source on GitHub ↗
(_key: string, value: string)

Source from the content-addressed store, hash-verified

67
68const QUOTED_VALUE_REGEXP = /^"(?<value>.*)"$/;
69function parseValue(_key: string, value: string) {
70 if (value === "null") return null;
71 if (value === "true") return true;
72 if (value === "false") return false;
73 const match = value.match(QUOTED_VALUE_REGEXP);
74 if (match) return match.groups?.value as string;
75 if (!isNaN(+value)) return +value;
76 return value;
77}
78
79/**
80 * Parse an INI config string into an object.

Callers 1

parseFunction · 0.85

Calls 1

matchMethod · 0.80

Tested by

no test coverage detected