MCPcopy Create free account
hub / github.com/DavidWells/analytics / format

Function format

packages/analytics-util-params/src/utils/formatValue.js:7–16  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

5 * @return {any} formatted value
6 */
7export default function format(value) {
8 if (value === '') return ''
9 if (value === 'true') return true
10 if (value === 'false') return false
11 /* Looks like JSON. Try to parse it */
12 if (value && value.match(/^(\{[^\n]+\})/)) {
13 try { return JSON.parse(value) } catch (err) {}
14 }
15 return isNaN(value) ? value : Number(value)
16}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected