// Wraps an object-like thing with a proxy to self-bind top-level functions const bindable = (base_class) => { return new Proxy(base_class, { get(target, property) { // If we're accessing a function of the item, force-bind it if ( typeof base_class[property] === 'function' && base_class.hasOwnProperty(property) ) { return base_class[property].bind(base_class) } return base_class[property] }, set(target, property, value) { base_class[property] = value } }) } // Async sleeper function const wait = (ms) => { return new Promise(resolve => { setTimeout(resolve, ms) }) } export { bindable, wait }