Skip to content

Instantly share code, notes, and snippets.

View damirka's full-sized avatar
There has to be an emoji for Capybara

Damir Shamanaev damirka

There has to be an emoji for Capybara
View GitHub Profile
@damirka
damirka / index.js
Created April 25, 2017 10:44
Using generators to execute async code in a sync manner
'use strict';
const EventEmitter = require('events');
/**
* Runs generator and puts EventEmitter context in it to let user
* emit any events inside generator and subscribe to them from outside.
*
* @param {Function} gen Function which returns generator
* @return {EventEmitter} Returns emitter instance which is bound