Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

diffOps.js 627B

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