File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -3427,6 +3427,14 @@ console.log(copiedBuf.toString());
34273427
34283428console .log (buf .toString ());
34293429// Prints: buffer
3430+
3431+ // With buf.slice(), the original buffer is modified.
3432+ const notReallyCopiedBuf = buf .slice ();
3433+ notReallyCopiedBuf[0 ]++ ;
3434+ console .log (notReallyCopiedBuf .toString ());
3435+ // Prints: cuffer
3436+ console .log (buf .toString ());
3437+ // Also prints: cuffer (!)
34303438```
34313439
34323440``` cjs
@@ -3441,6 +3449,14 @@ console.log(copiedBuf.toString());
34413449
34423450console .log (buf .toString ());
34433451// Prints: buffer
3452+
3453+ // With buf.slice(), the original buffer is modified.
3454+ const notReallyCopiedBuf = buf .slice ();
3455+ notReallyCopiedBuf[0 ]++ ;
3456+ console .log (notReallyCopiedBuf .toString ());
3457+ // Prints: cuffer
3458+ console .log (buf .toString ());
3459+ // Also prints: cuffer (!)
34443460```
34453461
34463462### ` buf.swap16() `
You can’t perform that action at this time.
0 commit comments