contains.js 524 B

1234567891011121314151617
  1. import assertString from './util/assertString';
  2. import toString from './util/toString';
  3. import merge from './util/merge';
  4. var defaulContainsOptions = {
  5. ignoreCase: false,
  6. minOccurrences: 1
  7. };
  8. export default function contains(str, elem, options) {
  9. assertString(str);
  10. options = merge(options, defaulContainsOptions);
  11. if (options.ignoreCase) {
  12. return str.toLowerCase().split(toString(elem).toLowerCase()).length > options.minOccurrences;
  13. }
  14. return str.split(toString(elem)).length > options.minOccurrences;
  15. }