collection-delete-all.js 526 B

12345678910111213141516
  1. 'use strict';
  2. var anObject = require('../internals/an-object');
  3. var aFunction = require('../internals/a-function');
  4. // https://github.com/tc39/collection-methods
  5. module.exports = function (/* ...elements */) {
  6. var collection = anObject(this);
  7. var remover = aFunction(collection['delete']);
  8. var allDeleted = true;
  9. var wasDeleted;
  10. for (var k = 0, len = arguments.length; k < len; k++) {
  11. wasDeleted = remover.call(collection, arguments[k]);
  12. allDeleted = allDeleted && wasDeleted;
  13. }
  14. return !!allDeleted;
  15. };