Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Last active December 18, 2015 04:09
Show Gist options
  • Save apaleslimghost/5723401 to your computer and use it in GitHub Desktop.
Save apaleslimghost/5723401 to your computer and use it in GitHub Desktop.
visionmedia/co + curried functions
const co = require('co'),
fs = require('fs'),
curry = require('prelude-ls').curry;
var read = curry(fs.readFile());
co(function* () {
var a = yield read('.gitignore','utf8');
var b = yield read('Makefile','utf8');
var c = yield read('package.json','utf8');
console.log(a,b,c);
});
require! {co, fs, 'prelude-ls'.curry}
read = curry fs.read-file
co -*>
a = yield read '.gitignore' \utf8
b = yield read 'Makefile' \utf8
c = yield read 'package.json' \utf8
console.log a,b,c
@apaleslimghost
Copy link
Author

nb that's a hypothetical future LiveScript with support for generators and yield

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment