@@ -1884,7 +1884,8 @@ changes:
1884
1884
-->
1885
1885
1886
1886
* ` value ` {string|Buffer|Uint8Array|integer} The value with which to fill ` buf ` .
1887
- * ` offset ` {integer} Number of bytes to skip before starting to fill ` buf ` .
1887
+ Empty value (string, Uint8Array, Buffer) is coerced to ` 0 ` .
1888
+ * ` offset ` {integer} Number of bytes to skip before starting to fill ` buf `
1888
1889
** Default:** ` 0 ` .
1889
1890
* ` end ` {integer} Where to stop filling ` buf ` (not inclusive). ** Default:**
1890
1891
[ ` buf.length ` ] [ ] .
@@ -1904,6 +1905,12 @@ const b = Buffer.allocUnsafe(50).fill('h');
1904
1905
1905
1906
console .log (b .toString ());
1906
1907
// Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
1908
+
1909
+ // Fill a buffer with empty string
1910
+ const c = Buffer .allocUnsafe (5 ).fill (' ' );
1911
+
1912
+ console .log (c .fill (' ' ));
1913
+ // Prints: <Buffer 00 00 00 00 00>
1907
1914
```
1908
1915
1909
1916
``` cjs
@@ -1915,6 +1922,12 @@ const b = Buffer.allocUnsafe(50).fill('h');
1915
1922
1916
1923
console .log (b .toString ());
1917
1924
// Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
1925
+
1926
+ // Fill a buffer with empty string
1927
+ const c = Buffer .allocUnsafe (5 ).fill (' ' );
1928
+
1929
+ console .log (c .fill (' ' ));
1930
+ // Prints: <Buffer 00 00 00 00 00>
1918
1931
```
1919
1932
1920
1933
` value ` is coerced to a ` uint32 ` value if it is not a string, ` Buffer ` , or
0 commit comments