Skip to content

Instantly share code, notes, and snippets.

View branneman's full-sized avatar

Bran van der Meer branneman

View GitHub Profile
@branneman
branneman / prefixEventListener.js
Created February 10, 2017 10:23
Prefix EventListener
/**
* Capitalize
*/
const capitalize = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
/**
* Prefix EventListener
*/
@branneman
branneman / Observer.js
Created September 5, 2016 14:08 — forked from peeke/observer.js
Used for inter-object communication. (Semi-)drop in replacement for Rik Schennink's Observer.
/**
* Used for inter-object communication.
* (Semi-)drop in replacement for Rik Schennink's Observer.
*
* Implementation differences:
* - ES6
* - The use of WeakMaps
* - inform() and conceal() don't return a boolean indicating success.
* - Subscription fn's are called with seperate arguments, instead of one data parameter. This is backwards compatible.
*
// (c) copyright unscriptable.com / John Hann
// License MIT
// For more robust promises, see https://github.com/briancavalier/when.js.
function Promise () {
this._thens = [];
}
Promise.prototype = {