* The Buffer() constructor is deprecated in documentation and should not be * used moving forward. Rather, developers should use one of the three new * factory APIs: Buffer.from(), Buffer.allocUnsafe() or Buffer.alloc() based on * their specific needs. There is no runtime deprecation because of t
(arg, encodingOrOffset, length)
| 297 | * @returns {Buffer} |
| 298 | */ |
| 299 | function Buffer(arg, encodingOrOffset, length) { |
| 300 | showFlaggedDeprecation(); |
| 301 | // Common case. |
| 302 | if (typeof arg === 'number') { |
| 303 | if (typeof encodingOrOffset === 'string') { |
| 304 | throw new ERR_INVALID_ARG_TYPE('string', 'string', arg); |
| 305 | } |
| 306 | return Buffer.alloc(arg); |
| 307 | } |
| 308 | return Buffer.from(arg, encodingOrOffset, length); |
| 309 | } |
| 310 | |
| 311 | ObjectDefineProperty(Buffer, SymbolSpecies, { |
| 312 | __proto__: null, |
nothing calls this directly
no test coverage detected
searching dependent graphs…