$.collection-to-json.js 352 B

1234567891011
  1. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  2. var forOf = require('./$.for-of')
  3. , classof = require('./$.classof');
  4. module.exports = function(NAME){
  5. return function toJSON(){
  6. if(classof(this) != NAME)throw TypeError(NAME + "#toJSON isn't generic");
  7. var arr = [];
  8. forOf(this, false, arr.push, arr);
  9. return arr;
  10. };
  11. };