Skip to content

Instantly share code, notes, and snippets.

View OliverJAsh's full-sized avatar

Oliver Joseph Ash OliverJAsh

View GitHub Profile
@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 / 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.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 / 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 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
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 / bar-es6.js
Last active August 29, 2015 14:09
sandboxed-module error with transitive ES6 deps
export default 'bar';
@OliverJAsh
OliverJAsh / README.md
Created November 13, 2014 20:38
sandboxed-module test with ES6 source transformer
npm install
node traceur-runner.js main.js
@OliverJAsh
OliverJAsh / bar.js
Created November 14, 2014 19:24
sandboxed-module test with transitive dependencies
module.exports = 'bar';
/* jshint esnext: true */
// `getStream` is some third party thing
var stream = getStream();
var events = Rx.fromEvent(stream, 'meta');
stream.write('foo');
// meta event fired by `stream`
stream.write(null);