From 46854951b5cae5c97247c1bb9179eb86eb3e0a47 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 --- 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: {