lib/index.js
function each(cfg) {
	return function(callback) {
		return new Promise(function(resolve, reject) {

			// create an array to store callbacks
			var rl, cbs = [];
			
			// create an interface
			try {
				rl = readline.createInterface(cfg);
			}
			catch(err) {
				return reject(err);
			}
			
			// handle a new line
			rl.on('line', function(line) {
				cbs.push(callback(line));
			});
			
			// handle close
			rl.on('close', function() {
				Promise.all(cbs).then(function() {
					resolve({
						lines: cbs.length
					});
				})
				.caught(function(err) {
					reject(err);
				});
			});
		});
	};
}
function each(cfg) {
	return function(callback) {
		return new Promise(function(resolve, reject) {

			// create an array to store callbacks
			var rl, cbs = [];
			
			// create an interface
			try {
				rl = readline.createInterface(cfg);
			}
			catch(err) {
				return reject(err);
			}
			
			// handle a new line
			rl.on('line', function(line) {
				cbs.push(callback(line));
			});
			
			// handle close
			rl.on('close', function() {
				Promise.all(cbs).then(function() {
					resolve({
						lines: cbs.length
					});
				})
				.caught(function(err) {
					reject(err);
				});
			});
		});
	};
}
function each ( cfg ) { return function ( callback ) { return new Promise ( function ( resolve , reject ) { // create an array to store callbacks var rl , cbs = [ ] ; // create an interface try { rl = readline . createInterface ( cfg ) ; } catch ( err ) { return reject ( err ) ; } // handle a new line rl . on ( 'line' , function ( line ) { cbs . push ( callback ( line ) ) ; } ) ; // handle close rl . on ( 'close' , function ( ) { Promise . all ( cbs ) . then ( function ( ) { resolve ( { lines : cbs . length } ) ; } ) . caught ( function ( err ) { reject ( err ) ; } ) ; } ) ; } ) ; } ; }
calls the callback on each line then resolves the callbacks if they are promises
calls the callback on each line then resolves the callbacks if they are promises