json-joy
Version:
Collection of libraries for building collaborative editing apps.
18 lines (17 loc) • 457 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.strCnt = void 0;
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;
}
};
exports.strCnt = strCnt;
;