diff options
Diffstat (limited to 'lib/internal/encoding.js')
-rw-r--r-- | lib/internal/encoding.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 16de0c986e..d1b4cbfe9b 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -3,7 +3,11 @@ // An implementation of the WHATWG Encoding Standard // https://encoding.spec.whatwg.org -const { Object } = primordials; +const { + ObjectCreate, + ObjectDefineProperties, + ObjectGetOwnPropertyDescriptors, +} = primordials; const { ERR_ENCODING_INVALID_ENCODED_DATA, @@ -339,7 +343,7 @@ class TextEncoder { if (typeof depth === 'number' && depth < 0) return this; const ctor = getConstructorOf(this); - const obj = Object.create({ + const obj = ObjectCreate({ constructor: ctor === null ? TextEncoder : ctor }); obj.encoding = this.encoding; @@ -348,7 +352,7 @@ class TextEncoder { } } -Object.defineProperties( +ObjectDefineProperties( TextEncoder.prototype, { 'encode': { enumerable: true }, 'encodeInto': { enumerable: true }, @@ -508,9 +512,9 @@ function makeTextDecoderJS() { // Mix in some shared properties. { - Object.defineProperties( + ObjectDefineProperties( TextDecoder.prototype, - Object.getOwnPropertyDescriptors({ + ObjectGetOwnPropertyDescriptors({ get encoding() { validateDecoder(this); return this[kEncoding]; @@ -532,7 +536,7 @@ function makeTextDecoderJS() { if (typeof depth === 'number' && depth < 0) return this; const ctor = getConstructorOf(this); - const obj = Object.create({ + const obj = ObjectCreate({ constructor: ctor === null ? TextDecoder : ctor }); obj.encoding = this.encoding; @@ -546,7 +550,7 @@ function makeTextDecoderJS() { return require('internal/util/inspect').inspect(obj, opts); } })); - Object.defineProperties(TextDecoder.prototype, { + ObjectDefineProperties(TextDecoder.prototype, { decode: { enumerable: true }, [inspect]: { enumerable: false }, [Symbol.toStringTag]: { |