esnext.map.delete-all.js 633 B

123456789101112131415161718
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var aMap = require('../internals/a-map');
  4. var remove = require('../internals/map-helpers').remove;
  5. // `Map.prototype.deleteAll` method
  6. // https://github.com/tc39/proposal-collection-methods
  7. $({ target: 'Map', proto: true, real: true, forced: true }, {
  8. deleteAll: function deleteAll(/* ...elements */) {
  9. var collection = aMap(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. });