(that, size, fill, encoding)
| 461 | } |
| 462 | |
| 463 | function alloc (that, size, fill, encoding) { |
| 464 | assertSize(size) |
| 465 | if (size <= 0) { |
| 466 | return createBuffer(that, size) |
| 467 | } |
| 468 | if (fill !== undefined) { |
| 469 | // Only pay attention to encoding if it's a string. This |
| 470 | // prevents accidentally sending in a number that would |
| 471 | // be interpretted as a start offset. |
| 472 | return typeof encoding === 'string' |
| 473 | ? createBuffer(that, size).fill(fill, encoding) |
| 474 | : createBuffer(that, size).fill(fill) |
| 475 | } |
| 476 | return createBuffer(that, size) |
| 477 | } |
| 478 | |
| 479 | /** |
| 480 | * Creates a new filled Buffer instance. |
no test coverage detected