Skip to content

Files

Latest commit

 

History

History
19 lines (13 loc) · 453 Bytes

no-new-buffer.md

File metadata and controls

19 lines (13 loc) · 453 Bytes

Pattern: Use of deprecated new Buffer() constructor

Issue: -

Description

The new Buffer() constructor has been deprecated since Node.js 4. Use Buffer.from() for creating a buffer from existing data or Buffer.alloc() for creating a new buffer with allocated memory.

Examples

Example of incorrect code:

const buffer = new Buffer(10);

Example of correct code:

const buffer = Buffer.alloc(10);