esnext.set.delete-all.js 633 B

123456789101112131415161718
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var aSet = require('../internals/a-set');
  4. var remove = require('../internals/set-helpers').remove;
  5. // `Set.prototype.deleteAll` method
  6. // https://github.com/tc39/proposal-collection-methods
  7. $({ target: 'Set', proto: true, real: true, forced: true }, {
  8. deleteAll: function deleteAll(/* ...elements */) {
  9. var collection = aSet(this);
  10. var allDeleted = true;
  11. var wasDeleted;
  12. for (var k = 0, len = arguments.length; k < len; k++) {
  13. wasDeleted = remove(collection, arguments[k]);
  14. allDeleted = allDeleted && wasDeleted;
  15. } return !!allDeleted;
  16. }
  17. });