my-idlers/node_modules/es5-ext/string/#/count.js
cp6 fd22b0bf58 V2 (Laravel re-make)
V2 (Laravel re-make)
2022-03-06 02:02:12 +11:00

16 lines
399 B
JavaScript

"use strict";
var ensureString = require("../../object/validate-stringifiable-value");
module.exports = function (search) {
var string = ensureString(this), count = 0, index = 0;
search = ensureString(search);
if (!search) throw new TypeError("Search string cannot be empty");
while ((index = string.indexOf(search, index)) !== -1) {
++count;
index += search.length;
}
return count;
};