Gates to make an async callback to a synchronized syntax. This should be used with co.
Gate module to guard asynchronous API with a callback. It works nicely with co.
co is a great solution to remove callbacks from your apps.
But you should change async apis to Thunks or Promises.
co-gate protects you from complex callback syntax, but also from changing existing apis.
This module is inspired by chan.
A most important difference is handling parallel async apis.
co-gate will stop at
yield before all callback returned and return array with multiple values.
npm install co-gate
// require covar co = require'co'Gate = require'co-gate'fs = require'fs';co// create gatevar gate =val = ;// just call normal apis with gate.in() as callbackfsreadFile"test/test1.txt" "utf-8" gatein;fsreadFile"test/test2.txt" "utf-8" gatein;try// yieldedval = yield gateout;catcheconsole.loge;assertequalval0 'test1';assertequalval1 'test2';;