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.

30 lines
721 B

4 years ago
  1. 'use strict';
  2. var variadic = require('../helpers/variadic');
  3. module.exports = function except() {
  4. var _this = this;
  5. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  6. args[_key] = arguments[_key];
  7. }
  8. var properties = variadic(args);
  9. if (Array.isArray(this.items)) {
  10. var _collection = this.items.filter(function (item) {
  11. return properties.indexOf(item) === -1;
  12. });
  13. return new this.constructor(_collection);
  14. }
  15. var collection = {};
  16. Object.keys(this.items).forEach(function (property) {
  17. if (properties.indexOf(property) === -1) {
  18. collection[property] = _this.items[property];
  19. }
  20. });
  21. return new this.constructor(collection);
  22. };