(size, fill, encoding)
| 282 | } |
| 283 | |
| 284 | function alloc (size, fill, encoding) { |
| 285 | assertSize(size) |
| 286 | if (size <= 0) { |
| 287 | return createBuffer(size) |
| 288 | } |
| 289 | if (fill !== undefined) { |
| 290 | // Only pay attention to encoding if it's a string. This |
| 291 | // prevents accidentally sending in a number that would |
| 292 | // be interpretted as a start offset. |
| 293 | return typeof encoding === 'string' |
| 294 | ? createBuffer(size).fill(fill, encoding) |
| 295 | : createBuffer(size).fill(fill) |
| 296 | } |
| 297 | return createBuffer(size) |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Creates a new filled Buffer instance. |
no test coverage detected