(that, size, fill, encoding)
| 765 | } |
| 766 | |
| 767 | function alloc (that, size, fill, encoding) { |
| 768 | assertSize(size) |
| 769 | if (size <= 0) { |
| 770 | return createBuffer(that, size) |
| 771 | } |
| 772 | if (fill !== undefined) { |
| 773 | // Only pay attention to encoding if it's a string. This |
| 774 | // prevents accidentally sending in a number that would |
| 775 | // be interpretted as a start offset. |
| 776 | return typeof encoding === 'string' |
| 777 | ? createBuffer(that, size).fill(fill, encoding) |
| 778 | : createBuffer(that, size).fill(fill) |
| 779 | } |
| 780 | return createBuffer(that, size) |
| 781 | } |
| 782 | |
| 783 | /** |
| 784 | * Creates a new filled Buffer instance. |
no test coverage detected