util: don't set the prototype of callbackified functions · nodejs/node@b5ea925 (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -194,7 +194,6 @@ function callbackify(original) {
194 194 (rej) => process.nextTick(callbackifyOnRejected, rej, cb));
195 195 }
196 196
197 -Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
198 197 const descriptors = Object.getOwnPropertyDescriptors(original);
199 198 // It is possible to manipulate a functions `length` or `name` property. This
200 199 // guards against the manipulation.
Original file line number Diff line number Diff line change
@@ -157,6 +157,11 @@ const values = [
157 157
158 158 const cbAsyncFn = callbackify(asyncFn);
159 159 assert.strictEqual(cbAsyncFn.length, 2);
160 +assert.notStrictEqual(
161 +Object.getPrototypeOf(cbAsyncFn),
162 +Object.getPrototypeOf(asyncFn)
163 +);
164 +assert.strictEqual(Object.getPrototypeOf(cbAsyncFn), Function.prototype);
160 165 cbAsyncFn(value, common.mustCall((err, ret) => {
161 166 assert.ifError(err);
162 167 assert.strictEqual(ret, value);