Dashboard sipadu mbip
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.

contains.js 994B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  3. var values = require('../helpers/values');
  4. module.exports = function contains(key, value) {
  5. if (value !== undefined) {
  6. if (Array.isArray(this.items)) {
  7. return this.items.filter(function (items) {
  8. return items[key] !== undefined && items[key] === value;
  9. }).length > 0;
  10. }
  11. return this.items[key] !== undefined && this.items[key] === value;
  12. }
  13. if (typeof key === 'function') {
  14. return this.items.filter(function (item, index) {
  15. return key(item, index);
  16. }).length > 0;
  17. }
  18. if (Array.isArray(this.items)) {
  19. return this.items.indexOf(key) !== -1;
  20. }
  21. var keysAndValues = values(this.items);
  22. keysAndValues.push.apply(keysAndValues, _toConsumableArray(Object.keys(this.items)));
  23. return keysAndValues.indexOf(key) !== -1;
  24. };