MCPcopy Index your code
hub / github.com/nodejs/node / Buffer

Function Buffer

lib/buffer.js:299–309  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

297 * @returns {Buffer}
298 */
299function 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
311ObjectDefineProperty(Buffer, SymbolSpecies, {
312 __proto__: null,

Callers

nothing calls this directly

Calls 3

showFlaggedDeprecationFunction · 0.85
allocMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…