Node-Red configuration
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.

set-symmetric-difference.js 740B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var aSet = require('../internals/a-set');
  3. var SetHelpers = require('../internals/set-helpers');
  4. var clone = require('../internals/set-clone');
  5. var getSetRecord = require('../internals/get-set-record');
  6. var iterateSimple = require('../internals/iterate-simple');
  7. var add = SetHelpers.add;
  8. var has = SetHelpers.has;
  9. var remove = SetHelpers.remove;
  10. // `Set.prototype.symmetricDifference` method
  11. // https://github.com/tc39/proposal-set-methods
  12. module.exports = function symmetricDifference(other) {
  13. var O = aSet(this);
  14. var keysIter = getSetRecord(other).getIterator();
  15. var result = clone(O);
  16. iterateSimple(keysIter, function (e) {
  17. if (has(O, e)) remove(result, e);
  18. else add(result, e);
  19. });
  20. return result;
  21. };