(that, size, fill, encoding)
| 2034 | } |
| 2035 | |
| 2036 | function alloc (that, size, fill, encoding) { |
| 2037 | assertSize(size); |
| 2038 | if (size <= 0) { |
| 2039 | return createBuffer(that, size) |
| 2040 | } |
| 2041 | if (fill !== undefined) { |
| 2042 | // Only pay attention to encoding if it's a string. This |
| 2043 | // prevents accidentally sending in a number that would |
| 2044 | // be interpretted as a start offset. |
| 2045 | return typeof encoding === 'string' |
| 2046 | ? createBuffer(that, size).fill(fill, encoding) |
| 2047 | : createBuffer(that, size).fill(fill) |
| 2048 | } |
| 2049 | return createBuffer(that, size) |
| 2050 | } |
| 2051 | |
| 2052 | /** |
| 2053 | * Creates a new filled Buffer instance. |
no test coverage detected