json-joy
Version:
Collection of libraries for building collaborative editing apps.
14 lines • 371 B
JavaScript
export const strCnt = (needle, haystack, offset = 0) => {
let cnt = 0;
const needleLen = needle.length;
if (needleLen === 0)
return 0;
while (true) {
const index = haystack.indexOf(needle, offset);
if (index < 0)
return cnt;
cnt++;
offset = index + needleLen;
}
};
//# sourceMappingURL=strCnt.js.map