Skip to content

Instantly share code, notes, and snippets.

View rbuckton's full-sized avatar

Ron Buckton rbuckton

View GitHub Profile
@rbuckton
rbuckton / example.ts
Last active June 15, 2017 22:32 — forked from mattpodwysocki/example.ts
Reimagining events as async iterables
const EventEmitter = require('events').EventEmitter;
const fromEventPattern = require('ix/asynciterable/fromeventpattern').fromEventPattern;
// Get Async Iterable
const e = new EventEmitter();
const ai = fromEventPattern(
h => e.addListener('data', h),
h => e.removeListener('data', h)
);
'use strict';
class MapAsyncIterable<T, R> implements AsyncIterable<R> {
private _source: Iterable<T | PromiseLike<T>> | AsyncIterable<T>;
private _selector: (value: T) => R | PromiseLike<R>;
constructor(source: Iterable<T | PromiseLike<T>> | AsyncIterable<T>, selector: (value: T) => R | PromiseLike<R>) {
this._source = source;
this._selector = selector;
}
@rbuckton
rbuckton / sourcemap-mediatypes.md
Last active August 29, 2015 14:03 — forked from fitzgen/gist:35d7e3905a915238aa14
Proposal for addition of MediaTypes to the Source Map spec.

Proposed Format

/* 1.*/  {
/* 2.*/    "version": 3,
/* 3.*/    "file": "out.js",
/* 4.*/    "sourceRoot": "",
/* 5.*/    "sources": ["foo.js", "bar.ts"],
/* 6.*/    "sourcesContent": [null, null],
/* 7.*/ "names": ["src", "maps", "are", "fun"],