UNPKG

@modern-kit/utils

Version:
19 lines (16 loc) 552 B
import { flatMap } from '../../array/flatMap/index.mjs'; import { isNil } from '../../validator/isNil/index.mjs'; import '../../array/flatten/index.mjs'; function trimStart(str, chars) { if (isNil(chars)) { return str.trimStart(); } const charsToUse = Array.isArray(chars) ? flatMap(chars, (char) => char.split("")) : chars; let startIndex = 0; while (startIndex < str.length && charsToUse.includes(str[startIndex])) { startIndex++; } return str.substring(startIndex); } export { trimStart }; //# sourceMappingURL=index.mjs.map