**:
//資料的分批寫入
let fs =
require
('fs');
let path =
require
('path');
//1.生成讀取和寫入的路徑
let readpath = path.
join
(__dirname,
"test.mp4");
let writepath = path.
join
(__dirname,
"abc.mp4");
//第一種複製方式
/*//2.建立乙個讀取流
let readstream = fs.createreadstream(readpath);
//3.建立乙個寫入流
let writestream = fs.createwritestream(writepath);
//4.監聽讀取流的事件
readstream.on("open", function () );
readstream.on("error", function () );
readstream.on("data", function (data) );
readstream.on("close", function () );
//5.監聽寫入流的事件
writestream.on("open", function () );
writestream.on("error", function () );
writestream.on("close", function () );*/
//第二種方式,管道符複製:
//2.建立乙個讀取流
let readstream = fs.
createreadstream
(readpath)
;//3.建立乙個寫入流
let writestream = fs.
createwritestream
(writepath)
;//利用讀取流的管道方法實現快速檔案拷貝,內部的實現其實就是上面的寫法
readstream.
pipe
(writestream)
;
使用第一種方式複製:
檔案大小無誤
第二種方式複製
大小無誤
NOTE 1 複製使用者許可權
event1 訊息 log unable to read local eventlog reason 引數錯誤。make sure the following service is started.windows event log depandency task scheduler windows...
js深複製淺複製
深淺複製主要是針對於js的引用資料型別的,因為他們不只一層,並且修改乙個變數是不希望修改到另外乙個變數。淺複製 只複製指向某個物件的指標,新舊物件共享一塊記憶體,修改新物件會改到原物件上。深複製 不共享記憶體,修改新物件不會改到原物件上。淺複製實現 js 簡單的賦值操作一般實現的都是淺複製。深複製實...
js物件複製
淺複製 var obj var obj1 var obj2 object.assign obj var obj var obj1 var obj2 object.assign obj obj.c.push 2 var obj var copyobj json parse json stringify...