Page 133 - Nodejs 교과서 개정2판
P. 133

pipeח झ౟ܿ ࢎ੉ী ৈ۞ ߣ োѾೡ ࣻ ੓णפ׮  ׮਺ ௏٘ח ౵ੌਸ ੍਷ റ H[JQ ߑधਵ۽ ঑୷ೞח ௏٘ੑ

         פ׮

          gzip.js

           const	zlib	=	require('zlib');
           const	fs	=	require('fs');


           const	readStream	=	fs.createReadStream('./readme4.txt');
           const	zlibStream	=	zlib.createGzip();
           const	writeStream	=	fs.createWriteStream('./readme4.txt.gz');
           readStream.pipe(zlibStream).pipe(writeStream);




         ֢٘ীࢲח ౵ੌਸ ঑୷ೞח [MJC੉ۄח ݽٕب ઁҕ೤פ׮  ੉ ଼ীࢲח ݆੉ ࢎਊೞ૑ ঋਵ޲۽ ٮ۽ ࢸݺೞ૑
         ח ঋणפ׮  ׮݅ [MJC੄ createGzip੉ۄח ݫࢲ٘о झ౟ܿਸ ૑ਗೞ޲۽ readStreamҗ writeStream ઺рী

         ࢲ ౵੉ೝਸ ೡ ࣻ ੓णפ׮  ߡಌ ؘ੉ఠо ੹׳غ׮о H[JQ ঑୷ਸ Ѣ஘ റ ౵ੌ۽ ॄ૘פ׮

          콘솔

           $	node	gzip




         SFBENF  UYU H[ ౵ੌ੉ ࢤࢿؾפ׮  ঑୷ػ ౵ੌ੉ۄ ղਊޛਸ ੍ӝח ൨ٟפ׮

         ੉ۧѱ ੹୓ ౵ੌਸ ݽف ߡಌী ੷੢ೞח readFile ݫࢲ٘৬ ࠗ࠙ਵ۽ աׇ ੍ח createRead Stream ݫࢲ٘ܳ
         ঌইࠌणפ׮  ੉ ف ݫࢲ٘੄ ݫݽܻ ࢎਊ۝੉ ঴݃ա ׮ܲ૑ पઁ۽ ഛੋ೧ࠁѷणפ׮


         ׮਺਷  (# ਊ۝੄ ఫझ౟ ౵ੌਸ ݅٘ח ௏٘ੑפ׮  ݢ੷ അ੤ ٘ۄ੉࠳ী ୽࠙ೠ ਊ۝੉ թই ੓ח૑ ഛੋೞ
         Ҋ प೯೧ঠ ೤פ׮  दр੉ ઑӘ ݆੉ ࣗਃؼ ࣻ ੓णפ׮


          createBigFile.js
           const	fs	=	require('fs');
           const	file	=	fs.createWriteStream('./big.txt');


           for	(let	i	=	0;	i	<=	10000000;	i++)	{
           		file.write('안녕하세요.	엄청나게	큰	파일을	만들어	볼	것입니다.	각오	단단히	하세요!\n');
           }
           file.end();




          콘솔

           $	node	createBigFile




         readFile ݫࢲ٘ܳ ࢎਊೞৈ CJH UYUܳ CJH  UYU۽ ࠂࢎ೧ࠁѷणפ׮
   128   129   130   131   132   133   134   135   136   137   138