co
co copied to clipboard
using co with node 0.10.x?
Hi,
co's home page says:
When using node 0.10.x and lower or browsers without generator support, you must use gnode and/or regenerator.
but when gnode an app, got:
ReferenceError: Promise is not defined
at co (.../node_modules/co/index.js:50:14)
is there a way to polyfill this with Bluebird? or what is the version of co that can be used with node 0.10.x?
Thanks, A.C.
co@4+
requires aPromise
implementation. For versions of node< 0.11
and for many older browsers, you should/must include your ownPromise
polyfill.
So yeah, you should do global.Promise = require('bluebird')
or similar.
Yes you can override global.Promise
. Also, check out this current PR for "bring your own promise" in this repo. Kind of interesting (and related) https://github.com/tj/co/pull/244
@madbence @joshbeam yeah, this will work for most of the cases, but we using co
in test framework ava and including global polyfill will affect code under testing (if code relies on Promise object, but don't polyfill it in test).