(fn, value, ctx)
| 2231 | } |
| 2232 | |
| 2233 | function formatPrimitive(fn, value, ctx) { |
| 2234 | if (typeof value === 'string') { |
| 2235 | let trailer = ''; |
| 2236 | if (value.length > ctx.maxStringLength) { |
| 2237 | const remaining = value.length - ctx.maxStringLength; |
| 2238 | value = StringPrototypeSlice(value, 0, ctx.maxStringLength); |
| 2239 | trailer = `... ${remaining} more character${remaining > 1 ? 's' : ''}`; |
| 2240 | } |
| 2241 | if (ctx.compact !== true && |
| 2242 | // We do not support handling unicode characters width with |
| 2243 | // the readline getStringWidth function as there are |
| 2244 | // performance implications. |
| 2245 | value.length > kMinLineLength && |
| 2246 | value.length > ctx.breakLength - ctx.indentationLvl - 4) { |
| 2247 | return ArrayPrototypeJoin( |
| 2248 | ArrayPrototypeMap( |
| 2249 | RegExpPrototypeSymbolSplit(/(?<=\n)/, value), |
| 2250 | (line) => fn(strEscape(line), 'string'), |
| 2251 | ), |
| 2252 | ` +\n${StringPrototypeRepeat(' ', ctx.indentationLvl + 2)}`, |
| 2253 | ) + trailer; |
| 2254 | } |
| 2255 | return fn(strEscape(value), 'string') + trailer; |
| 2256 | } |
| 2257 | if (typeof value === 'number') |
| 2258 | return formatNumber(fn, value, ctx.numericSeparator); |
| 2259 | if (typeof value === 'bigint') |
| 2260 | return formatBigInt(fn, value, ctx.numericSeparator); |
| 2261 | if (typeof value === 'boolean') |
| 2262 | return fn(`${value}`, 'boolean'); |
| 2263 | if (typeof value === 'undefined') |
| 2264 | return fn('undefined', 'undefined'); |
| 2265 | // es6 symbol primitive |
| 2266 | return fn(SymbolPrototypeToString(value), 'symbol'); |
| 2267 | } |
| 2268 | |
| 2269 | function formatNamespaceObject(keys, ctx, value, recurseTimes) { |
| 2270 | const output = new Array(keys.length); |
no test coverage detected
searching dependent graphs…