Skip to content

Instantly share code, notes, and snippets.

View OliverJAsh's full-sized avatar

Oliver Joseph Ash OliverJAsh

View GitHub Profile
@OliverJAsh
OliverJAsh / bar-es6.js
Last active August 29, 2015 14:09
sandboxed-module error with transitive ES6 deps
export default 'bar';
@OliverJAsh
OliverJAsh / README.md
Last active August 29, 2015 14:09
wrap: Nodeify the result of a promise returning function.

wrap

Nodeify the result of a promise returning function.

When an API requires that you pass it a function with the signature (...args, cb), wrap is a small helper that allows you to instead pass a promise returning function. wrap will nodeify the result of the promise returning function (fulfilment or rejection) by passing its value to the original callback.

Example

One such API that asks for an asynchronous listener function (...args, cb) is express. When a HTTP request is made, express will call your listener function, if you have one registered for that route. The example below demonstrates how wrap can help you to use promises in such a situation.

@OliverJAsh
OliverJAsh / foo.js
Created November 13, 2014 11:47
Given some nested data, what are the different options for logging in Node?
/**
* Given some nested data, what are the different options for logging in Node?
*/
var a = [
{
"data": {
"url": "http://theguardian.com/",
"feeds": [
{
@OliverJAsh
OliverJAsh / README.md
Created November 13, 2014 09:17
longjohn interoperability with Traceur call stacks
npm install
node traceur-runner.js main.js
@OliverJAsh
OliverJAsh / foo.js
Created November 12, 2014 14:55
DI: ApiClient -> HttpAdapter
/* jshint esnext: true */
import * as di from 'di/src';
class HttpAdapter {
constructor() {
console.log('HttpAdapter constructor');
}
}
class ApiClient {
@OliverJAsh
OliverJAsh / foo.js
Created November 12, 2014 14:46
DI: Car -> Engine
/* jshint esnext: true */
import * as di from 'di/src';
class Car {
constructor(engine) {
console.log('Car constructor engine: %s', engine);
}
}
// TODO: Fix ES6 class annotations
// As per: https://github.com/angular/di.js/issues/80
@OliverJAsh
OliverJAsh / foo.md
Last active August 29, 2015 14:08
API question

POST /feeds

{ "url": "<feedURL>" }

Description: Creates a feed from <feedUrl> by making a HTTP request to the feed URL and saving it to the database.

This operation will fail if (in order):

@OliverJAsh
OliverJAsh / README.md
Created October 30, 2014 16:31
Traceur error
npm install
./node_modules/.bin/traceur --out out.js test.js

node main.js
@OliverJAsh
OliverJAsh / README.md
Created October 30, 2014 11:56
jspm test
jspm install
npm i http-server
./node_modules/.bin/http-server -c-1 -o -p 8081
@OliverJAsh
OliverJAsh / README.md
Last active August 29, 2015 14:08
longjohn interoperability with Traceur call stacks
npm install
node traceur-runner.js main.js