Skip to content

Buffer() 和 new Buffer() 官方不在推荐使用, 针对字符串的入参请使用 Buffer.from() 构造函数。#8

Open
szfdiwang wants to merge 2 commits intoAlayaNetwork:masterfrom
szfdiwang:master
Open

Buffer() 和 new Buffer() 官方不在推荐使用, 针对字符串的入参请使用 Buffer.from() 构造函数。#8
szfdiwang wants to merge 2 commits intoAlayaNetwork:masterfrom
szfdiwang:master

Conversation

@szfdiwang
Copy link
Collaborator

nodejs官方不在推荐new Buffer方法, 替换成Buffer.from

对于 new Buffer(number), 请用 Buffer.alloc(number) 替换。
对于 new Buffer(string) (或 new Buffer(string, encoding)),请用对应的 Buffer.from(string) (或 Buffer.from(string, encoding))进行替换。
对于其它情况(一般极为罕见)中使用了 new Buffer(...arguments) 的,请用 Buffer.from(...arguments) 进行替换。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant