string_decoder: refactor to use more primordials

PR-URL: https://github.com/nodejs/node/pull/36358
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Antoine du Hamel
2020-11-21 20:23:32 +01:00
committed by James M Snell
parent 7e5fc9c792
commit 4027e36dfd

View File

@@ -25,6 +25,7 @@ const {
ArrayBufferIsView,
ObjectDefineProperties,
Symbol,
TypedArrayPrototypeSubarray,
} = primordials;
const { Buffer } = require('buffer');
@@ -104,8 +105,9 @@ ObjectDefineProperties(StringDecoder.prototype, {
configurable: true,
enumerable: true,
get() {
return this[kNativeDecoder].subarray(kIncompleteCharactersStart,
kIncompleteCharactersEnd);
return TypedArrayPrototypeSubarray(this[kNativeDecoder],
kIncompleteCharactersStart,
kIncompleteCharactersEnd);
}
},
lastNeed: {