MCPcopy Create free account
hub / github.com/microsoft/SandDance / reduceToSingleString

Function reduceToSingleString

docs/tests/v2/es6/js/sanddance.js:8106–8119  ·  view source on GitHub ↗
(output, base, braces)

Source from the content-addressed store, hash-verified

8104}
8105
8106function reduceToSingleString(output, base, braces) {
8107 var numLinesEst = 0;
8108 var length = output.reduce(function (prev, cur) {
8109 numLinesEst++;
8110 if (cur.indexOf('\n') >= 0) numLinesEst++;
8111 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
8112 }, 0);
8113
8114 if (length > 60) {
8115 return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1];
8116 }
8117
8118 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
8119} // NOTE: These type checking functions intentionally don't use `instanceof`
8120// because it is fragile and can be easily faked with `Object.create()`.
8121
8122

Callers 1

formatValueFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected