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 @@ -3425,6 +3425,14 @@ console.log(copiedBuf.toString());
34253425
34263426console .log (buf .toString ());
34273427//  Prints: buffer
3428+ 
3429+ //  With buf.slice(), the original buffer is modified.
3430+ const  notReallyCopiedBuf  =  buf .slice ();
3431+ notReallyCopiedBuf[0 ]++ ;
3432+ console .log (notReallyCopiedBuf .toString ());
3433+ //  Prints: cuffer
3434+ console .log (buf .toString ());
3435+ //  Also prints: cuffer (!)
34283436``` 
34293437
34303438``` cjs 
@@ -3439,6 +3447,14 @@ console.log(copiedBuf.toString());
34393447
34403448console .log (buf .toString ());
34413449//  Prints: buffer
3450+ 
3451+ //  With buf.slice(), the original buffer is modified.
3452+ const  notReallyCopiedBuf  =  buf .slice ();
3453+ notReallyCopiedBuf[0 ]++ ;
3454+ console .log (notReallyCopiedBuf .toString ());
3455+ //  Prints: cuffer
3456+ console .log (buf .toString ());
3457+ //  Also prints: cuffer (!)
34423458``` 
34433459
34443460### ` buf.swap16() `  
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments