esnext.weak-map.delete-all.js 659 B

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