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

௒ߔ ૑ৠ਷ Promiseա async awaitਵ۽ যו ੿ب ೧Ѿೡ ࣻ ੓णפ׮

          asyncOrderPromise.js

           const	fs	=	require('fs').promises;


           console.log('시작');
           fs.readFile('./readme2.txt')
           		.then((data)	=>	{
           				console.log('1번',	data.toString());
           				return	fs.readFile('./readme2.txt');
           		})
           		.then((data)	=>	{
           				console.log('2번',	data.toString());
           				return	fs.readFile('./readme2.txt');
           		})
           		.then((data)	=>	{
           				console.log('3번',	data.toString());
           				console.log('끝');
           		})
           		.catch((err)	=>	{
           				console.error(err);
           		});




         प೯ Ѿҗח BTZOD0SEFS KT৬ эणפ׮

         ૑Әө૑ زӝ ݫࢲ٘৬ ࠺زӝ ݫࢲ٘੄ ର੉ܳ ঌইࠌणפ׮  ੉ઁ readFileҗ readFileSyncীࢲ ߉ইৡ dat

         aܳ data.toString()ਵ۽ ߸ജೞח ੉ਬܳ ঌইࠅ ର۹ੑפ׮  Ѿۿࠗఠ ݈ೞ੗ݶ toString ݫࢲ٘ܳ ࢎਊೞ

         ח ੉ਬח dataо ߡಌ੉ӝ ٸޙੑפ׮  ߡಌо ޖ঺ੋ૑ ঌইࠇद׮

          
          
               ߡಌ৬ झ౟ܿ ੉೧ೞӝ
         ౵ੌਸ ੍Ѣա ॳח ߑधীח ௼ѱ ف о૑ ߑध  ૊ ߡಌܳ ੉ਊೞח ߑधҗ झ౟ܿਸ ੉ਊೞח ߑध੉ ੓णפ

         ׮  ߡಌ݂җ झ౟ܻ߁੉ۄח ਊযܳ ٜযࠄ ੸੉ ੓աਃ  ই݃ ੋఠ֔ਵ۽ ৔࢚ਸ द୒ೡ ٸ ف ਊযܳ ࠄ ੸੉
         ੓ਸ ѩפ׮  ৔࢚ਸ ۽٬ೡ ٸח ߡಌ݂ೠ׮Ҋ ೞҊ  ৔࢚ਸ पदрਵ۽ ࣠୹ೡ ٸח झ౟ܻ߁ೠ׮Ҋ ೤פ׮


         ߡಌ݂਷ ৔࢚ਸ ੤ࢤೡ ࣻ ੓ਸ ٸө૑ ؘ੉ఠܳ ݽਵח ز੘੉Ҋ  झ౟ܻ߁਷ ߑ࣠ੋ੄ ஹೊఠীࢲ द୒੗੄
         ஹೊఠ۽ ৔࢚ ؘ੉ఠܳ ઑӘঀ ੹࣠ೞח ز੘ੑפ׮  झ౟ܻ߁ೞח җ੿ীࢲ ߡಌ݂ਸ ೡ ࣻب ੓णפ׮  ੹࣠

         ੉ ցޖ וܻݶ ചݶਸ ղࠁղӝө૑ ୭ࣗೠ੄ ؘ੉ఠܳ ݽইঠ ೞҊ  ৔࢚ ؘ੉ఠо ੤ࢤ ࣘبࠁ׮ ࡅܰѱ ੹࣠
         غযب ޷ܻ ੹࣠߉਷ ؘ੉ఠܳ ੷੢ೡ ҕр੉ ೙ਃೞӝ ٸޙੑפ׮


         ֢٘੄ ߡಌ৬ झ౟ܿب ࠺तೠ ѐ֛ੑפ׮  খীࢲ readFile ݫࢲ٘ܳ ࢎਊೡ ٸ ੍঻؍ ౵ੌ੉ ߡಌ ഋधਵ۽
   123   124   125   126   127   128   129   130   131   132   133