mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
249bb8da2f
Ensure the wrapped class prototype is exactly the unwrapped class prototype, rather than an object whose prototype is the unwrapped class prototype. This ensures that instances of the unwrapped class are instances of the wrapped class. This is useful when both a wrapped class and a factory for the unwrapped class are both exposed. Ref: https://github.com/nodejs/node/pull/8103 PR-URL: https://github.com/nodejs/node/pull/8105 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
16 lines
455 B
JavaScript
16 lines
455 B
JavaScript
const util = require('util');
|
|
const assert = require('assert');
|
|
|
|
class deprecatedClass {
|
|
}
|
|
|
|
const deprecated = util.deprecate(deprecatedClass, 'deprecatedClass is deprecated.');
|
|
|
|
const instance = new deprecated();
|
|
const deprecatedInstance = new deprecatedClass();
|
|
|
|
assert(instance instanceof deprecated);
|
|
assert(instance instanceof deprecatedClass);
|
|
assert(deprecatedInstance instanceof deprecated);
|
|
assert(deprecatedInstance instanceof deprecatedClass);
|