(size, fill, encoding)
| 2804 | } |
| 2805 | |
| 2806 | function alloc (size, fill, encoding) { |
| 2807 | assertSize(size) |
| 2808 | if (size <= 0) { |
| 2809 | return createBuffer(size) |
| 2810 | } |
| 2811 | if (fill !== undefined) { |
| 2812 | // Only pay attention to encoding if it's a string. This |
| 2813 | // prevents accidentally sending in a number that would |
| 2814 | // be interpretted as a start offset. |
| 2815 | return typeof encoding === 'string' |
| 2816 | ? createBuffer(size).fill(fill, encoding) |
| 2817 | : createBuffer(size).fill(fill) |
| 2818 | } |
| 2819 | return createBuffer(size) |
| 2820 | } |
| 2821 | |
| 2822 | /** |
| 2823 | * Creates a new filled Buffer instance. |
no test coverage detected
searching dependent graphs…