Skip to content

Instantly share code, notes, and snippets.

View cancerberoSgx's full-sized avatar

Sebastián Gurin cancerberoSgx

  • home
  • Montevideo, Uruguay
View GitHub Profile
@cancerberoSgx
cancerberoSgx / promisified-hyperquest.js
Created May 10, 2018 05:44 — forked from nikcorg/promisified-hyperquest.js
Promisified Hyperquest -- A quick exercise wrapping Hyperquest in a Promise for an easy thenable API.
var concat = require("concat-stream");
var hyperquest = require("hyperquest");
var stream = require("stream");
// Wait for the request to finish or fail
function promisify(req) {
return new Promise(function (resolve, reject) {
req.on("error", reject).pipe(concat({ encoding: "string" }, resolve));
});