DEP0005:Buffer() 构造函数


🌐 DEP0005: Buffer() constructor

类型:应用(仅限非 node_modules 代码)

🌐 Type: Application (non-node_modules code only)

Buffer() 函数和 new Buffer() 构造函数由于 API 可用性问题而被弃用,这些问题可能导致意外的安全问题。

🌐 The Buffer() function and new Buffer() constructor are deprecated due to API usability issues that can lead to accidental security issues.

作为替代,可以使用以下方法之一来构建 Buffer 对象:

🌐 As an alternative, use one of the following methods of constructing Buffer objects:

如果没有使用 --pending-deprecation,运行时警告只会针对不在 node_modules 中的代码触发。这意味着使用依赖中的 Buffer() 不会产生弃用警告。使用 --pending-deprecation 后,无论 Buffer() 使用在何处,都会产生运行时警告。

🌐 Without --pending-deprecation, runtime warnings occur only for code not in node_modules. This means there will not be deprecation warnings for Buffer() usage in dependencies. With --pending-deprecation, a runtime warning results no matter where the Buffer() usage occurs.