Skip to content

Commit 0b70822

Browse files
aduh95codebytere
authored andcommitted
child_process: refactor to use more primordials
PR-URL: #36003 Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 34aa0c8 commit 0b70822

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎lib/internal/child_process/serialization.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
const{
44
JSONParse,
55
JSONStringify,
6+
StringPrototypeSplit,
67
Symbol,
8+
TypedArrayPrototypeSubarray,
79
}=primordials;
810
const{ Buffer }=require('buffer');
911
const{ StringDecoder }=require('string_decoder');
@@ -63,8 +65,8 @@ const advanced = {
6365
}
6466

6567
constdeserializer=newChildProcessDeserializer(
66-
messageBuffer.subarray(4,4+size));
67-
messageBuffer=messageBuffer.subarray(4+size);
68+
TypedArrayPrototypeSubarray(messageBuffer,4,4+size));
69+
messageBuffer=TypedArrayPrototypeSubarray(messageBuffer,4+size);
6870

6971
deserializer.readHeader();
7072
yielddeserializer.readValue();
@@ -98,7 +100,8 @@ const json = {
98100

99101
if(channel[kStringDecoder]===undefined)
100102
channel[kStringDecoder]=newStringDecoder('utf8');
101-
constchunks=channel[kStringDecoder].write(readData).split('\n');
103+
constchunks=
104+
StringPrototypeSplit(channel[kStringDecoder].write(readData),'\n');
102105
constnumCompleteChunks=chunks.length-1;
103106
// Last line does not have trailing linebreak
104107
constincompleteChunk=chunks[numCompleteChunks];

0 commit comments

Comments
 (0)