Instantly share code, notes, and snippets.

View prefixEventListener.js
/**
* Capitalize
*/
const capitalize = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
/**
* Prefix EventListener
*/
View Observer.js
/**
* 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.
*
View tiny Promise.js
// (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 = {