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

• concat(배열)  ߓৌ উী ٚ ߡಌٜਸ ೞա۽ ೤஝פ׮

            • alloc(바이트)  ࠼ ߡಌܳ ࢤࢿ೤פ׮  ߄੉౟ܳ ੋࣻ۽ ֍ਵݶ ೧׼ ௼ӝ੄ ߡಌо ࢤࢿؾפ׮
          
         readFile ߑध੄ ߡಌо ಞܻೞӝח ೞ૑݅ ޙઁ੼ب ੓णפ׮  ݅ড ਊ۝੉    .#ੋ ౵ੌ੉ ੓ਵݶ ੍ਸ ٸ
         ݫݽܻী    .#੄ ߡಌܳ ٜ݅যঠ ೤פ׮  ੉ ੘সਸ زदী ৌ ѐ݅ ೧ب  (#ী ׳ೞח ݫݽܻо ࢎਊؾפ

         ׮  ౠ൤ ࢲߡ୊ۢ ݻ ݺ੉ ੉ਊೡ૑ ݽܰח ജ҃ীࢲח ݫݽܻ ޙઁо ߊࢤೡ ࣻ ੓णפ׮

         ژೠ  ݽٚ ղਊਸ ߡಌী ׮ ॵ റীঠ ׮਺ ز੘ਵ۽ ֈযо޲۽ ౵ੌ ੍ӝ  ঑୷  ౵ੌ ॳӝ ١੄ ઑ੘ਸ ো׳

         ই ೡ ٸ ݒߣ ੹୓ ਊ۝ਸ ߡಌ۽ ୊ܻ೧ঠ ׮਺ ױ҅۽ ֈযт ࣻ ੓णפ׮

         Ӓېࢲ ߡಌ੄ ௼ӝܳ ੘ѱ ݅ٚ റ ৈ۞ ߣਵ۽ աׇ ࠁղח ߑध੉ ١੢೮णפ׮  ৘ܳ ٜݶ ߡಌ  .#ܳ ݅ٚ

         റ    .# ౵ੌਸ ߔ ߣী Ѧ୛ࢲ աׇ ࠁղח Ѫੑפ׮  ੉۽ॄ ݫݽܻ  .#۽    .# ౵ੌਸ ੹࣠ೡ ࣻ ੓ण
         פ׮  ੉ܳ ಞܻೞѱ ݅ٚ Ѫ੉ झ౟ܿੑפ׮

















         § Ӓܿ      झ౟ܿ


         ౵ੌਸ ੍ח झ౟ܿ ݫࢲ٘۽ח createReadStream੉ ੓णפ׮  ׮਺җ э੉ ࢎਊ೤פ׮


          readme3.txt
           저는	조금씩	조금씩	나눠서	전달됩니다.	나눠진	조각을	chunk라고	부릅니다.




          createReadStream.js

           const	fs	=	require('fs');


           const	readStream	=	fs.createReadStream('./readme3.txt',	{	highWaterMark:	16	});
           const	data	=	[];


           readStream.on('data',	(chunk)	=>	{
           		data.push(chunk);
           		console.log('data	:',	chunk,	chunk.length);
           });


           readStream.on('end',	()	=>	{
           		console.log('end	:',	Buffer.concat(data).toString());
           });
   125   126   127   128   129   130   131   132   133   134   135