MCPcopy Create free account
hub / github.com/cli-table/cli-table3 / truncate

Function truncate

src/utils.js:186–205  ·  view source on GitHub ↗
(str, desiredLength, truncateChar)

Source from the content-addressed store, hash-verified

184}
185
186function truncate(str, desiredLength, truncateChar) {
187 truncateChar = truncateChar || '…';
188 let lengthOfStr = strlen(str);
189 if (lengthOfStr <= desiredLength) {
190 return str;
191 }
192 desiredLength -= strlen(truncateChar);
193
194 let ret = truncateWidthWithAnsi(str, desiredLength);
195
196 ret += truncateChar;
197
198 const hrefTag = '\x1B]8;;\x07';
199
200 if (str.includes(hrefTag) && !ret.includes(hrefTag)) {
201 ret += hrefTag;
202 }
203
204 return ret;
205}
206
207function defaultOptions() {
208 return {

Callers 1

utils-test.jsFile · 0.85

Calls 2

strlenFunction · 0.85
truncateWidthWithAnsiFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…