MCPcopy Create free account
hub / github.com/BridgeAR/safe-stable-stringify / stringifyPrimitive

Function stringifyPrimitive

index.js:581–599  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

579 }
580
581 let stringifyPrimitive = function (value) {
582 switch (typeof value) {
583 case 'string':
584 return strEscape(value)
585 case 'number':
586 return isFinite(value) ? String(value) : fail ? fail(value) : 'null'
587 case 'boolean':
588 return value === true ? 'true' : 'false'
589 case 'undefined':
590 return undefined
591 case 'bigint':
592 if (bigint) {
593 return bigint === 'string' ? `"${value}"` : String(value)
594 }
595 // fallthrough
596 default:
597 return fail ? fail(value) : undefined
598 }
599 }
600
601 let stringifyObject = function (key, value, stack) {
602 if (value === null) {

Callers 4

stringifyArrayReplacerFunction · 0.85
stringifyIndentFunction · 0.85
stringifyObjectFunction · 0.85
stringifyFunction · 0.85

Calls 1

strEscapeFunction · 0.85

Tested by

no test coverage detected