what if you did this:

if(Object.getPrototypeOf(out) !== Object.getPrototypeOf(chunk))