Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected results in CoffeeScript #10

Open
akidee opened this issue Apr 14, 2011 · 0 comments
Open

Unexpected results in CoffeeScript #10

akidee opened this issue Apr 14, 2011 · 0 comments

Comments

@akidee
Copy link
Contributor

akidee commented Apr 14, 2011

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 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant