esnext.set.join.js 743 B

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