async.js icon indicating copy to clipboard operation
async.js copied to clipboard

Unexpected results in CoffeeScript

Open akidee opened this issue 15 years ago • 0 comments

This is generated code from CoffeeScript that runs in node 0.4.5 and with latest asyncjs. I use the "=>" operator, that prefixes a function's body and preserves the current context (this):

var async;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
async = require('asyncjs');
async.list([1, 2, 3]).forEach(__bind(function(name, next) {
  return next(null, name);
}, this)).toArray(false, function(e, f) {
  return console.log(f);
});

Result:

[ 1, 2, 3 ]
[ 1, 2, 3, 3 ]
[ 1, 2, 3, 3, 2 ]
[ 1, 2, 3, 3, 2, 1 ]

Instead of:

[ 1, 2, 3 ]

akidee avatar Apr 14 '11 17:04 akidee