From 0db9101922bf090f0d6c31d928617e7745bdeafd Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 21 Nov 2020 20:23:32 +0100 Subject: [PATCH] string_decoder: refactor to use more primordials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/36358 Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- lib/string_decoder.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/string_decoder.js b/lib/string_decoder.js index 3d2cc2fcb6ab51..2891e0a1d1a43a 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -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: {