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

Function stringify

index.js:601–622  ·  view source on GitHub ↗
(value, replacer, space)

Source from the content-addressed store, hash-verified

599 }
600
601 function stringify (value, replacer, space) {
602 if (arguments.length > 1) {
603 let spacer = ''
604 if (typeof space === 'number') {
605 spacer = ' '.repeat(Math.min(space, 10))
606 } else if (typeof space === 'string') {
607 spacer = space.slice(0, 10)
608 }
609 if (replacer != null) {
610 if (typeof replacer === 'function') {
611 return stringifyFnReplacer('', { '': value }, [], replacer, spacer, '')
612 }
613 if (Array.isArray(replacer)) {
614 return stringifyArrayReplacer('', value, [], getUniqueReplacerSet(replacer), spacer, '')
615 }
616 }
617 if (spacer.length !== 0) {
618 return stringifyIndent('', value, [], spacer, '')
619 }
620 }
621 return stringifySimple('', value, [])
622 }
623
624 return stringify
625}

Callers 2

benchmark.jsFile · 0.85
test.jsFile · 0.85

Calls 5

stringifyFnReplacerFunction · 0.85
stringifyArrayReplacerFunction · 0.85
getUniqueReplacerSetFunction · 0.85
stringifyIndentFunction · 0.85
stringifySimpleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…