File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3409,6 +3409,14 @@ console.log(copiedBuf.toString());
34093409
34103410console .log (buf .toString ());
34113411// Prints: buffer
3412+
3413+ // With buf.slice(), the original buffer is modified.
3414+ const notReallyCopiedBuf = buf .slice ();
3415+ notReallyCopiedBuf[0 ]++ ;
3416+ console .log (notReallyCopiedBuf .toString ());
3417+ // Prints: cuffer
3418+ console .log (buf .toString ());
3419+ // Also prints: cuffer (!)
34123420```
34133421
34143422``` cjs
@@ -3423,6 +3431,14 @@ console.log(copiedBuf.toString());
34233431
34243432console .log (buf .toString ());
34253433// Prints: buffer
3434+
3435+ // With buf.slice(), the original buffer is modified.
3436+ const notReallyCopiedBuf = buf .slice ();
3437+ notReallyCopiedBuf[0 ]++ ;
3438+ console .log (notReallyCopiedBuf .toString ());
3439+ // Prints: cuffer
3440+ console .log (buf .toString ());
3441+ // Also prints: cuffer (!)
34263442```
34273443
34283444### ` buf.swap16() `
You can’t perform that action at this time.
0 commit comments