Skip to content

Instantly share code, notes, and snippets.

View plemarquand's full-sized avatar

Paul LeMarquand plemarquand

  • Apple
  • Ottawa, Ontario
  • 10:48 (UTC -04:00)
View GitHub Profile
@plemarquand
plemarquand / waitUntil.js
Created February 27, 2015 20:43
Bacon.waitUntil
/**
* Waits until the supplied stream emits a value, and then
* continues by emitting the last value emitted on the target.
* Useful when you want to gate on an event emitter.
*/
Bacon.Observable.prototype.waitUntil = function(item) {
// Cache the last value to come out of the source.
let last;
const unsub = this.onValue(x => last = x);
@plemarquand
plemarquand / fromBifurcatedCallback.js
Created February 27, 2015 20:21
Bacon.fromBifurcatedCallback
/**
* Similar to Bacon.fromNodeCallback except instead of a single callback,
* the value and error result are split to two different callbacks.
* Works for the form method(...args, successCallback, errorCallback);
* This style of API is used by https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
*/
Bacon.fromBifurcatedCallback = function(method, ...args) {
return Bacon.fromBinder(sink => {
args.push(res => {
sink(res);
@plemarquand
plemarquand / Gruntfile.js
Created April 21, 2014 19:11
Gruntfile: Relative sourcemap paths with grunt-browserify and mold-source-map
module.exports = function(grunt) {
// load only required grunt tasks as tasks are run
require('jit-grunt')(grunt);
// Project configuration.
grunt.initConfig({
browserify : {
files : {
'test/browserified_unit_tests.js' : 'test/spec/**.js'