esnext.set.join.js 839 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var uncurryThis = require('../internals/function-uncurry-this');
  4. var anObject = require('../internals/an-object');
  5. var toString = require('../internals/to-string');
  6. var getSetIterator = require('../internals/get-set-iterator');
  7. var iterate = require('../internals/iterate');
  8. var arrayJoin = uncurryThis([].join);
  9. var push = [].push;
  10. // `Set.prototype.join` method
  11. // https://github.com/tc39/proposal-collection-methods
  12. $({ target: 'Set', proto: true, real: true, forced: true }, {
  13. join: function join(separator) {
  14. var set = anObject(this);
  15. var iterator = getSetIterator(set);
  16. var sep = separator === undefined ? ',' : toString(separator);
  17. var result = [];
  18. iterate(iterator, push, { that: result, IS_ITERATOR: true });
  19. return arrayJoin(result, sep);
  20. }
  21. });