I'm trying to create a subclass of NodeJS's buffer. I tried the following:
const SubClass = Object.create(Buffer)
SubClass.prototype.isZero = function () {
for(const value of this.buffer) { // Fails on this line
...
}
}
Then I do the following
SubClass.from([0, 0]).isZero()
It throws
TypeError: undefined is not a function
But this.buffer is defined. So whats the problem (maybe an iterator problem?)? Am I doing something wrong with extending the buffer?
this.buffer[Symbol.iterator]must not be a function.isZerocall, becausefromwill return an instance ofBufferall the time no matter what.isZerothen shouldn't exist there.