web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
399 B

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