diffKeys.js 433 B

1234567891011121314151617
  1. 'use strict';
  2. module.exports = function diffKeys(object) {
  3. var objectToDiff;
  4. if (object instanceof this.constructor) {
  5. objectToDiff = object.all();
  6. } else {
  7. objectToDiff = object;
  8. }
  9. var objectKeys = Object.keys(objectToDiff);
  10. var remainingKeys = Object.keys(this.items).filter(function (item) {
  11. return objectKeys.indexOf(item) === -1;
  12. });
  13. return new this.constructor(this.items).only(remainingKeys);
  14. };