Skip to content

Commit 20aaf6f

Browse files
committed
fs: replace native methods with primordials
Replace native methods with primordials.
1 parent 879b95e commit 20aaf6f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/internal/fs/read/context.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const {
44
ArrayPrototypePush,
55
FunctionPrototypeCall,
66
MathMin,
7+
TypedArrayPrototypeSlice,
78
} = primordials;
89

910
const {
@@ -36,7 +37,7 @@ function readFileAfterRead(err, bytesRead) {
3637
if (context.size === 0) {
3738
// Unknown size, just read until we don't get bytes.
3839
const buffer = bytesRead === kReadFileUnknownBufferLength ?
39-
context.buffer : context.buffer.slice(0, bytesRead);
40+
context.buffer : TypedArrayPrototypeSlice(context.buffer, 0, bytesRead);
4041
ArrayPrototypePush(context.buffers, buffer);
4142
}
4243
context.read();
@@ -55,7 +56,7 @@ function readFileAfterClose(err) {
5556
if (context.size === 0)
5657
buffer = Buffer.concat(context.buffers, context.pos);
5758
else if (context.pos < context.size)
58-
buffer = context.buffer.slice(0, context.pos);
59+
buffer = TypedArrayPrototypeSlice(context.buffer, 0, context.pos);
5960
else
6061
buffer = context.buffer;
6162

0 commit comments

Comments
 (0)