isIn.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  6. exports.default = isIn;
  7. var _assertString = require('./util/assertString');
  8. var _assertString2 = _interopRequireDefault(_assertString);
  9. var _toString = require('./util/toString');
  10. var _toString2 = _interopRequireDefault(_toString);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. function isIn(str, options) {
  13. (0, _assertString2.default)(str);
  14. var i = void 0;
  15. if (Object.prototype.toString.call(options) === '[object Array]') {
  16. var array = [];
  17. for (i in options) {
  18. if ({}.hasOwnProperty.call(options, i)) {
  19. array[i] = (0, _toString2.default)(options[i]);
  20. }
  21. }
  22. return array.indexOf(str) >= 0;
  23. } else if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') {
  24. return options.hasOwnProperty(str);
  25. } else if (options && typeof options.indexOf === 'function') {
  26. return options.indexOf(str) >= 0;
  27. }
  28. return false;
  29. }
  30. module.exports = exports['default'];