contains.js 936 B

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = contains;
  6. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7. var _toString = _interopRequireDefault(require("./util/toString"));
  8. var _merge = _interopRequireDefault(require("./util/merge"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. var defaulContainsOptions = {
  11. ignoreCase: false,
  12. minOccurrences: 1
  13. };
  14. function contains(str, elem, options) {
  15. (0, _assertString.default)(str);
  16. options = (0, _merge.default)(options, defaulContainsOptions);
  17. if (options.ignoreCase) {
  18. return str.toLowerCase().split((0, _toString.default)(elem).toLowerCase()).length > options.minOccurrences;
  19. }
  20. return str.split((0, _toString.default)(elem)).length > options.minOccurrences;
  21. }
  22. module.exports = exports.default;
  23. module.exports.default = exports.default;