MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / represent

Function represent

src/run_tests.mjs:107–114  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

105}
106
107function represent(val) {
108 if (typeof val == "boolean") return String(val)
109 if (typeof val == "number") return String(val)
110 if (typeof val == "string") return JSON.stringify(val)
111 if (val == null) return String(val)
112 if (Array.isArray(val)) return representArray(val)
113 else return representObj(val)
114}
115
116function representArray(val) {
117 let out = "["

Callers 3

representArrayFunction · 0.70
representSimpleObjFunction · 0.70
run_tests.mjsFile · 0.70

Calls 2

representArrayFunction · 0.70
representObjFunction · 0.70

Tested by

no test coverage detected