MCPcopy Index your code
hub / github.com/nodejs/node / isBelowBreakLength

Function isBelowBreakLength

lib/internal/util/inspect.js:2614–2636  ·  view source on GitHub ↗
(ctx, output, start, base)

Source from the content-addressed store, hash-verified

2612}
2613
2614function isBelowBreakLength(ctx, output, start, base) {
2615 // Each entry is separated by at least a comma. Thus, we start with a total
2616 // length of at least `output.length`. In addition, some cases have a
2617 // whitespace in-between each other that is added to the total as well.
2618 // TODO(BridgeAR): Add unicode support. Use the readline getStringWidth
2619 // function. Check the performance overhead and make it an opt-in in case it's
2620 // significant.
2621 let totalLength = output.length + start;
2622 if (totalLength + output.length > ctx.breakLength)
2623 return false;
2624 for (let i = 0; i < output.length; i++) {
2625 if (ctx.colors) {
2626 totalLength += removeColors(output[i]).length;
2627 } else {
2628 totalLength += output[i].length;
2629 }
2630 if (totalLength > ctx.breakLength) {
2631 return false;
2632 }
2633 }
2634 // Do not line up properties on the same line if `base` contains line breaks.
2635 return base === '' || !StringPrototypeIncludes(base, '\n');
2636}
2637
2638function reduceToSingleString(
2639 ctx, output, base, braces, extrasType, recurseTimes, value) {

Callers 1

reduceToSingleStringFunction · 0.85

Calls 1

removeColorsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…