| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 072adfe commit b229912
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,8 +22,6 @@ resized. | |||
| 22 | 22 | The `Buffer` class is a global within Node.js, making it unlikely that one | |
| 23 | 23 | would need to ever use `require('buffer').Buffer`. | |
| 24 | 24 | ||
| 25 | - Examples: | ||
| 26 | - | ||
| 27 | 25 | ```js | |
| 28 | 26 | // Creates a zero-filled Buffer of length 10. | |
| 29 | 27 | const buf1 = Buffer.alloc(10); | |
@@ -489,8 +487,6 @@ changes: | |||
| 489 | 487 | Creates a new `Buffer` containing the given JavaScript string `string`. If | |
| 490 | 488 | provided, the `encoding` parameter identifies the character encoding of `string`. | |
| 491 | 489 | ||
| 492 | - Examples: | ||
| 493 | - | ||
| 494 | 490 | ```js | |
| 495 | 491 | const buf1 = new Buffer('this is a tést'); | |
| 496 | 492 | ||
@@ -896,8 +892,6 @@ added: v5.10.0 | |||
| 896 | 892 | Creates a new `Buffer` containing the given JavaScript string `string`. If | |
| 897 | 893 | provided, the `encoding` parameter identifies the character encoding of `string`. | |
| 898 | 894 | ||
| 899 | - Examples: | ||
| 900 | - | ||
| 901 | 895 | ```js | |
| 902 | 896 | const buf1 = Buffer.from('this is a tést'); | |
| 903 | 897 | ||
@@ -1052,8 +1046,6 @@ Comparison is based on the actual sequence of bytes in each `Buffer`. | |||
| 1052 | 1046 | * `1` is returned if `target` should come *before* `buf` when sorted. | |
| 1053 | 1047 | * `-1` is returned if `target` should come *after* `buf` when sorted. | |
| 1054 | 1048 | ||
| 1055 | - Examples: | ||
| 1056 | - | ||
| 1057 | 1049 | ```js | |
| 1058 | 1050 | const buf1 = Buffer.from('ABC'); | |
| 1059 | 1051 | const buf2 = Buffer.from('BCD'); | |
@@ -1083,8 +1075,6 @@ The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd` | |||
| 1083 | 1075 | arguments can be used to limit the comparison to specific ranges within `target` | |
| 1084 | 1076 | and `buf` respectively. | |
| 1085 | 1077 | ||
| 1086 | - Examples: | ||
| 1087 | - | ||
| 1088 | 1078 | ```js | |
| 1089 | 1079 | const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]); | |
| 1090 | 1080 | const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]); | |
@@ -1196,8 +1186,6 @@ changes: | |||
| 1196 | 1186 | Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes, | |
| 1197 | 1187 | `false` otherwise. | |
| 1198 | 1188 | ||
| 1199 | - Examples: | ||
| 1200 | - | ||
| 1201 | 1189 | ```js | |
| 1202 | 1190 | const buf1 = Buffer.from('ABC'); | |
| 1203 | 1191 | const buf2 = Buffer.from('414243', 'hex'); | |
@@ -1277,8 +1265,6 @@ added: v5.3.0 | |||
| 1277 | 1265 | ||
| 1278 | 1266 | Equivalent to [`buf.indexOf() !== -1`][`buf.indexOf()`]. | |
| 1279 | 1267 | ||
| 1280 | - Examples: | ||
| 1281 | - | ||
| 1282 | 1268 | ```js | |
| 1283 | 1269 | const buf = Buffer.from('this is a buffer'); | |
| 1284 | 1270 | ||
@@ -1334,8 +1320,6 @@ If `value` is: | |||
| 1334 | 1320 | * a number, `value` will be interpreted as an unsigned 8-bit integer | |
| 1335 | 1321 | value between `0` and `255`. | |
| 1336 | 1322 | ||
| 1337 | - Examples: | ||
| 1338 | - | ||
| 1339 | 1323 | ```js | |
| 1340 | 1324 | const buf = Buffer.from('this is a buffer'); | |
| 1341 | 1325 | ||
@@ -1441,8 +1425,6 @@ changes: | |||
| 1441 | 1425 | Identical to [`buf.indexOf()`], except `buf` is searched from back to front | |
| 1442 | 1426 | instead of front to back. | |
| 1443 | 1427 | ||
| 1444 | - Examples: | ||
| 1445 | - | ||
| 1446 | 1428 | ```js | |
| 1447 | 1429 | const buf = Buffer.from('this buffer is a buffer'); | |
| 1448 | 1430 | ||
@@ -1535,8 +1517,6 @@ can result in undefined and inconsistent behavior. Applications that wish to | |||
| 1535 | 1517 | modify the length of a `Buffer` should therefore treat `length` as read-only and | |
| 1536 | 1518 | use [`buf.slice()`] to create a new `Buffer`. | |
| 1537 | 1519 | ||
| 1538 | - Examples: | ||
| 1539 | - | ||
| 1540 | 1520 | ```js | |
| 1541 | 1521 | let buf = Buffer.allocUnsafe(10); | |
| 1542 | 1522 | ||
@@ -1577,8 +1557,6 @@ little endian). | |||
| 1577 | 1557 | Setting `noAssert` to `true` allows `offset` to be beyond the end of `buf`, but | |
| 1578 | 1558 | the resulting behavior is undefined. | |
| 1579 | 1559 | ||
| 1580 | - Examples: | ||
| 1581 | - | ||
| 1582 | 1560 | ```js | |
| 1583 | 1561 | const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); | |
| 1584 | 1562 | ||
@@ -1613,8 +1591,6 @@ little endian). | |||
| 1613 | 1591 | Setting `noAssert` to `true` allows `offset` to be beyond the end of `buf`, but | |
| 1614 | 1592 | the resulting behavior is undefined. | |
| 1615 | 1593 | ||
| 1616 | - Examples: | ||
| 1617 | - | ||
| 1618 | 1594 | ```js | |
| 1619 | 1595 | const buf = Buffer.from([1, 2, 3, 4]); | |
| 1620 | 1596 | ||
@@ -1648,8 +1624,6 @@ the resulting behavior is undefined. | |||
| 1648 | 1624 | ||
| 1649 | 1625 | Integers read from a `Buffer` are interpreted as two's complement signed values. | |
| 1650 | 1626 | ||
| 1651 | - Examples: | ||
| 1652 | - | ||
| 1653 | 1627 | ```js | |
| 1654 | 1628 | const buf = Buffer.from([-1, 5]); | |
| 1655 | 1629 | ||
@@ -1682,8 +1656,6 @@ the resulting behavior is undefined. | |||
| 1682 | 1656 | ||
| 1683 | 1657 | Integers read from a `Buffer` are interpreted as two's complement signed values. | |
| 1684 | 1658 | ||
| 1685 | - Examples: | ||
| 1686 | - | ||
| 1687 | 1659 | ```js | |
| 1688 | 1660 | const buf = Buffer.from([0, 5]); | |
| 1689 | 1661 | ||
@@ -1716,8 +1688,6 @@ the resulting behavior is undefined. | |||
| 1716 | 1688 | ||
| 1717 | 1689 | Integers read from a `Buffer` are interpreted as two's complement signed values. | |
| 1718 | 1690 | ||
| 1719 | - Examples: | ||
| 1720 | - | ||
| 1721 | 1691 | ```js | |
| 1722 | 1692 | const buf = Buffer.from([0, 0, 0, 5]); | |
| 1723 | 1693 | ||
@@ -1749,8 +1719,6 @@ bits of accuracy. | |||
| 1749 | 1719 | Setting `noAssert` to `true` allows `offset` to be beyond the end of `buf`, but | |
| 1750 | 1720 | the resulting behavior is undefined. | |
| 1751 | 1721 | ||
| 1752 | - Examples: | ||
| 1753 | - | ||
| 1754 | 1722 | ```js | |
| 1755 | 1723 | const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); | |
| 1756 | 1724 | ||
@@ -1778,8 +1746,6 @@ Reads an unsigned 8-bit integer from `buf` at the specified `offset`. | |||
| 1778 | 1746 | Setting `noAssert` to `true` allows `offset` to be beyond the end of `buf`, but | |
| 1779 | 1747 | the resulting behavior is undefined. | |
| 1780 | 1748 | ||
| 1781 | - Examples: | ||
| 1782 | - | ||
| 1783 | 1749 | ```js | |
| 1784 | 1750 | const buf = Buffer.from([1, -2]); | |
| 1785 | 1751 | ||
@@ -1810,8 +1776,6 @@ returns little endian). | |||
| 1810 | 1776 | Setting `noAssert` to `true` allows `offset` to be beyond the end of `buf`, but | |
| 1811 | 1777 | the resulting behavior is undefined. | |
| 1812 | 1778 | ||
| 1813 | - Examples: | ||
| 1814 | - | ||
| 1815 | 1779 | ```js | |
| 1816 | 1780 | const buf = Buffer.from([0x12, 0x34, 0x56]); | |
| 1817 | 1781 | ||
@@ -1848,8 +1812,6 @@ specified endian format (`readUInt32BE()` returns big endian, | |||
| 1848 | 1812 | Setting `noAssert` to `true` allows `offset` to be beyond the end of `buf`, but | |
| 1849 | 1813 | the resulting behavior is undefined. | |
| 1850 | 1814 | ||
| 1851 | - Examples: | ||
| 1852 | - | ||
| 1853 | 1815 | ```js | |
| 1854 | 1816 | const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); | |
| 1855 | 1817 | ||
@@ -1881,8 +1843,6 @@ bits of accuracy. | |||
| 1881 | 1843 | Setting `noAssert` to `true` allows `offset` to be beyond the end of `buf`, but | |
| 1882 | 1844 | the resulting behavior is undefined. | |
| 1883 | 1845 | ||
| 1884 | - Examples: | ||
| 1885 | - | ||
| 1886 | 1846 | ```js | |
| 1887 | 1847 | const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); | |
| 1888 | 1848 | ||
@@ -1949,8 +1909,6 @@ console.log(buf2.toString('ascii', 0, buf2.length)); | |||
| 1949 | 1909 | Specifying negative indexes causes the slice to be generated relative to the | |
| 1950 | 1910 | end of `buf` rather than the beginning. | |
| 1951 | 1911 | ||
| 1952 | - Examples: | ||
| 1953 | - | ||
| 1954 | 1912 | ```js | |
| 1955 | 1913 | const buf = Buffer.from('buffer'); | |
| 1956 | 1914 | ||
@@ -1977,8 +1935,6 @@ added: v5.10.0 | |||
| 1977 | 1935 | Interprets `buf` as an array of unsigned 16-bit integers and swaps the byte-order | |
| 1978 | 1936 | *in-place*. Throws a `RangeError` if [`buf.length`] is not a multiple of 2. | |
| 1979 | 1937 | ||
| 1980 | - Examples: | ||
| 1981 | - | ||
| 1982 | 1938 | ```js | |
| 1983 | 1939 | const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); | |
| 1984 | 1940 | ||
@@ -2006,8 +1962,6 @@ added: v5.10.0 | |||
| 2006 | 1962 | Interprets `buf` as an array of unsigned 32-bit integers and swaps the byte-order | |
| 2007 | 1963 | *in-place*. Throws a `RangeError` if [`buf.length`] is not a multiple of 4. | |
| 2008 | 1964 | ||
| 2009 | - Examples: | ||
| 2010 | - | ||
| 2011 | 1965 | ```js | |
| 2012 | 1966 | const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); | |
| 2013 | 1967 | ||
@@ -2035,8 +1989,6 @@ added: v6.3.0 | |||
| 2035 | 1989 | Interprets `buf` as an array of 64-bit numbers and swaps the byte-order *in-place*. | |
| 2036 | 1990 | Throws a `RangeError` if [`buf.length`] is not a multiple of 8. | |
| 2037 | 1991 | ||
| 2038 | - Examples: | ||
| 2039 | - | ||
| 2040 | 1992 | ```js | |
| 2041 | 1993 | const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); | |
| 2042 | 1994 | ||
@@ -2103,8 +2055,6 @@ Decodes `buf` to a string according to the specified character encoding in | |||
| 2103 | 2055 | The maximum length of a string instance (in UTF-16 code units) is available | |
| 2104 | 2056 | as [`buffer.constants.MAX_STRING_LENGTH`][]. | |
| 2105 | 2057 | ||
| 2106 | - Examples: | ||
| 2107 | - | ||
| 2108 | 2058 | ```js | |
| 2109 | 2059 | const buf1 = Buffer.allocUnsafe(26); | |
| 2110 | 2060 | ||
@@ -2141,8 +2091,6 @@ added: v1.1.0 | |||
| 2141 | 2091 | Creates and returns an [iterator] for `buf` values (bytes). This function is | |
| 2142 | 2092 | called automatically when a `Buffer` is used in a `for..of` statement. | |
| 2143 | 2093 | ||
| 2144 | - Examples: | ||
| 2145 | - | ||
| 2146 | 2094 | ```js | |
| 2147 | 2095 | const buf = Buffer.from('buffer'); | |
| 2148 | 2096 | ||
@@ -2215,8 +2163,6 @@ endian). `value` *should* be a valid 64-bit double. Behavior is undefined when | |||
| 2215 | 2163 | Setting `noAssert` to `true` allows the encoded form of `value` to extend beyond | |
| 2216 | 2164 | the end of `buf`, but the resulting behavior is undefined. | |
| 2217 | 2165 | ||
| 2218 | - Examples: | ||
| 2219 | - | ||
| 2220 | 2166 | ```js | |
| 2221 | 2167 | const buf = Buffer.allocUnsafe(8); | |
| 2222 | 2168 | ||
@@ -2250,8 +2196,6 @@ endian). `value` *should* be a valid 32-bit float. Behavior is undefined when | |||
| 2250 | 2196 | Setting `noAssert` to `true` allows the encoded form of `value` to extend beyond | |
| 2251 | 2197 | the end of `buf`, but the resulting behavior is undefined. | |
| 2252 | 2198 | ||
| 2253 | - Examples: | ||
| 2254 | - | ||
| 2255 | 2199 | ```js | |
| 2256 | 2200 | const buf = Buffer.allocUnsafe(4); | |
| 2257 | 2201 | ||
@@ -2285,8 +2229,6 @@ the end of `buf`, but the resulting behavior is undefined. | |||
| 2285 | 2229 | ||
| 2286 | 2230 | `value` is interpreted and written as a two's complement signed integer. | |
| 2287 | 2231 | ||
| 2288 | - Examples: | ||
| 2289 | - | ||
| 2290 | 2232 | ```js | |
| 2291 | 2233 | const buf = Buffer.allocUnsafe(2); | |
| 2292 | 2234 | ||
@@ -2318,8 +2260,6 @@ the end of `buf`, but the resulting behavior is undefined. | |||
| 2318 | 2260 | ||
| 2319 | 2261 | `value` is interpreted and written as a two's complement signed integer. | |
| 2320 | 2262 | ||
| 2321 | - Examples: | ||
| 2322 | - | ||
| 2323 | 2263 | ```js | |
| 2324 | 2264 | const buf = Buffer.allocUnsafe(4); | |
| 2325 | 2265 | ||
@@ -2351,8 +2291,6 @@ the end of `buf`, but the resulting behavior is undefined. | |||
| 2351 | 2291 | ||
| 2352 | 2292 | `value` is interpreted and written as a two's complement signed integer. | |
| 2353 | 2293 | ||
| 2354 | - Examples: | ||
| 2355 | - | ||
| 2356 | 2294 | ```js | |
| 2357 | 2295 | const buf = Buffer.allocUnsafe(8); | |
| 2358 | 2296 | ||
@@ -2383,8 +2321,6 @@ anything other than a signed integer. | |||
| 2383 | 2321 | Setting `noAssert` to `true` allows the encoded form of `value` to extend beyond | |
| 2384 | 2322 | the end of `buf`, but the resulting behavior is undefined. | |
| 2385 | 2323 | ||
| 2386 | - Examples: | ||
| 2387 | - | ||
| 2388 | 2324 | ```js | |
| 2389 | 2325 | const buf = Buffer.allocUnsafe(6); | |
| 2390 | 2326 | ||
@@ -2416,8 +2352,6 @@ other than an unsigned 8-bit integer. | |||
| 2416 | 2352 | Setting `noAssert` to `true` allows the encoded form of `value` to extend beyond | |
| 2417 | 2353 | the end of `buf`, but the resulting behavior is undefined. | |
| 2418 | 2354 | ||
| 2419 | - Examples: | ||
| 2420 | - | ||
| 2421 | 2355 | ```js | |
| 2422 | 2356 | const buf = Buffer.allocUnsafe(4); | |
| 2423 | 2357 | ||
@@ -2449,8 +2383,6 @@ undefined when `value` is anything other than an unsigned 16-bit integer. | |||
| 2449 | 2383 | Setting `noAssert` to `true` allows the encoded form of `value` to extend beyond | |
| 2450 | 2384 | the end of `buf`, but the resulting behavior is undefined. | |
| 2451 | 2385 | ||
| 2452 | - Examples: | ||
| 2453 | - | ||
| 2454 | 2386 | ```js | |
| 2455 | 2387 | const buf = Buffer.allocUnsafe(4); | |
| 2456 | 2388 | ||
@@ -2486,8 +2418,6 @@ undefined when `value` is anything other than an unsigned 32-bit integer. | |||
| 2486 | 2418 | Setting `noAssert` to `true` allows the encoded form of `value` to extend beyond | |
| 2487 | 2419 | the end of `buf`, but the resulting behavior is undefined. | |
| 2488 | 2420 | ||
| 2489 | - Examples: | ||
| 2490 | - | ||
| 2491 | 2421 | ```js | |
| 2492 | 2422 | const buf = Buffer.allocUnsafe(4); | |
| 2493 | 2423 | ||
@@ -2522,8 +2452,6 @@ anything other than an unsigned integer. | |||
| 2522 | 2452 | Setting `noAssert` to `true` allows the encoded form of `value` to extend beyond | |
| 2523 | 2453 | the end of `buf`, but the resulting behavior is undefined. | |
| 2524 | 2454 | ||
| 2525 | - Examples: | ||
| 2526 | - | ||
| 2527 | 2455 | ```js | |
| 2528 | 2456 | const buf = Buffer.allocUnsafe(6); | |
| 2529 | 2457 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments