Skip to content

Instantly share code, notes, and snippets.

View pori's full-sized avatar
💃
Fabulous!

Alice Hernandez pori

💃
Fabulous!
View GitHub Profile
@lovasoa
lovasoa / partial-evaluation.js
Last active December 28, 2023 05:56
Partial-evaluation for javascript.
/** pe
* @argument f: the multiple-argument function to turn into a partially-evaluatable
* @returns : A single-argument function that applies its argument as the first argument of f, and returns the partially-evaluated function
* @exemple: pe((a,b)=>a+b)(9)(1) === 10
*/
function pe(f, context, args) {
if(!args) args = [];
if (args.length === f.length) return f.apply(context, args);
return function partial (a) {
var args_copy = args.concat.apply(args, arguments);
var fs = require("fs");
var mkdirp = require("mkdirp");
var path = require("path");
function fileStream(dest) {
mkdirp.sync(path.dirname(dest));
return fs.createWriteStream(dest);
}
var writableStream = fileStream("./somecontent.js");
@xgrommx
xgrommx / signal.js
Created April 25, 2016 01:16 — forked from L8D/signal.js
function Signal(sub) {
this.sub = sub;
}
Signal.prototype = {
/**
* Applies the given function over each event.
*/
map: function(fn) {
var sub = this.sub;

Minimum Viable Async with Node 6

With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.

This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async + await.

The promise