esnext.set.join.js 698 B

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