bt-sensors-plugin-sk
Version:
Bluetooth Sensors for Signalk - see https://www.npmjs.com/package/bt-sensors-plugin-sk#supported-sensors for a list of supported sensors
19 lines (16 loc) • 462 B
JavaScript
function bindThisToThat(obj1, obj2){
for (let method of getInstanceMethodNames(obj1)) {
obj1[method]=obj1[method].bind(obj2)
}
}
function getInstanceMethodNames (obj) {
return Object
.getOwnPropertyNames (Object.getPrototypeOf (obj))
.filter(name => (name !== 'constructor' && typeof obj[name] === 'function'));
}
class Mixin{
constructor(obj){
bindThisToThat(this, obj)
}
}
module.exports=Mixin