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

Function removeChars

lib/internal/data_url.js:330–343  ·  view source on GitHub ↗

* @param {string} str * @param {boolean} leading * @param {boolean} trailing * @param {(charCode: number) => boolean} predicate * @returns {string}

(str, leading, trailing, predicate)

Source from the content-addressed store, hash-verified

328 * @returns {string}
329 */
330function removeChars(str, leading, trailing, predicate) {
331 let lead = 0;
332 let trail = str.length - 1;
333
334 if (leading) {
335 while (lead < str.length && predicate(StringPrototypeCharCodeAt(str, lead))) lead++;
336 }
337
338 if (trailing) {
339 while (trail > 0 && predicate(StringPrototypeCharCodeAt(str, trail))) trail--;
340 }
341
342 return lead === 0 && trail === str.length - 1 ? str : StringPrototypeSlice(str, lead, trail + 1);
343}
344
345/**
346 * @see https://infra.spec.whatwg.org/#isomorphic-decode

Callers 1

removeASCIIWhitespaceFunction · 0.70

Calls 1

predicateFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…