UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

23 lines (21 loc) 556 B
function trimStart(str, chars) { if (chars === undefined) { return str.trimStart(); } let startIndex = 0; switch (typeof chars) { case 'string': { while (startIndex < str.length && str[startIndex] === chars) { startIndex++; } break; } case 'object': { while (startIndex < str.length && chars.includes(str[startIndex])) { startIndex++; } } } return str.substring(startIndex); } export { trimStart };