MCPcopy
hub / github.com/feross/buffer / alloc

Function alloc

index.js:190–204  ·  view source on GitHub ↗
(size, fill, encoding)

Source from the content-addressed store, hash-verified

188}
189
190function alloc (size, fill, encoding) {
191 assertSize(size)
192 if (size <= 0) {
193 return createBuffer(size)
194 }
195 if (fill !== undefined) {
196 // Only pay attention to encoding if it's a string. This
197 // prevents accidentally sending in a number that would
198 // be interpreted as a start offset.
199 return typeof encoding === 'string'
200 ? createBuffer(size).fill(fill, encoding)
201 : createBuffer(size).fill(fill)
202 }
203 return createBuffer(size)
204}
205
206/**
207 * Creates a new filled Buffer instance.

Callers 1

index.jsFile · 0.85

Calls 2

assertSizeFunction · 0.85
createBufferFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…