Message from JavaScript discussions

December 2017

— Welp it's frustrating to see reduce not work, haha

— 

Went with this instead of reduce:

Object.keys(tests).forEach(
name =>
this.boundTests[name] = tests[name].bind(this)
);

— I was missing rest operator somewhere but at that point forEach is simpler

— Heh, that would work, if I used singletons in the Kernel

— This works pretty well

— 

for (var name in this.prototype.SCP) {
this.SCP[name] = this.prototype.SCP[name].bind(this);
};

— Ayy

— Made a little utility function that does it for me

— Hmmm, should call it bindAssign :D

— 

stdLib.bindAssign = function (thisArg, toObj, ...objects) {
for (var obj in objects) {
for (var prop in obj) {
if ((typeof obj[prop]) === "function") {
toObj[prop] = obj[prop].bind(thisArg);
} else {
toObj[prop] = obj[prop];
}
};
}
return toObj;
};

better

Message permanent page

— 

this.sysCallProcedures = this.stdLib.bindAssign(this, {}, this.prototype.SCP);

— Nooooo capitalize classes please