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.

diffOps.js 679B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. var keys = require('object-keys');
  3. var forEach = require('foreach');
  4. var indexOf = require('array.prototype.indexof');
  5. module.exports = function diffOperations(actual, expected, expectedMissing) {
  6. var actualKeys = keys(actual);
  7. var expectedKeys = keys(expected);
  8. var extra = [];
  9. var missing = [];
  10. forEach(actualKeys, function (op) {
  11. if (!(op in expected)) {
  12. extra.push(op);
  13. } else if (indexOf(expectedMissing, op) !== -1) {
  14. extra.push(op);
  15. }
  16. });
  17. forEach(expectedKeys, function (op) {
  18. if (typeof actual[op] !== 'function' && indexOf(expectedMissing, op) === -1) {
  19. missing.push(op);
  20. }
  21. });
  22. return { missing: missing, extra: extra };
  23. };