Page 129 - Nodejs 교과서 개정2판
P. 129
۱غणפ ֢٘ח ੌਸ ੍ਸ ٸ ݫݽܻী ੌ ӝ݅ఀ ҕрਸ ݃۲೧فݴ ੌ ؘఠܳ ݫݽܻী
ೠ ٍ ࢎਊо ઑೡ ࣻ ب۾ פ ٸ ݫݽܻী ػ ؘఠо ߄۽ ߡಌੑפ
§ Ӓܿ ߡಌ
ৈӝী ߡಌܳ ܙ ࣻ ח ېझо णפ ߄۽ Bufferੑפ
buffer.js
const buffer = Buffer.from('저를 버퍼로 바꿔보세요');
console.log('from():', buffer);
console.log('length:', buffer.length);
console.log('toString():', buffer.toString());
const array = [Buffer.from('띄엄 '), Buffer.from('띄엄 '), Buffer.from('띄어쓰기')];
const buffer2 = Buffer.concat(array);
console.log('concat():', buffer2.toString());
const buffer3 = Buffer.alloc(5);
console.log('alloc():', buffer3);
콘솔
$ node buffer
from(): <Buffer ec a0 80 eb a5 bc 20 eb b2 84 ed 8d bc eb a1 9c 20 eb b0 94 ea bf 94 eb b3 b4 ec 84 b8 ec 9
a 94>
length: 32
toString(): 저를 버퍼로 바꿔보세요
concat(): 띄엄 띄엄 띄어쓰기
alloc(): <Buffer 00 00 00 00 00>
Buffer ёח ৈ۞ о ݫࢲ٘ܳ ઁҕפ
• from(문자열) ޙৌਸ ߡಌ۽ ߄Ե ࣻ णפ length ࣘࢿ ߡಌ ӝܳ ঌ݀פ ߄ ױਤੑ
פ
• toString(버퍼) ߡಌܳ द ޙৌ۽ ߄Ե ࣻ णפ ٸ CBTF ա IFYܳ ੋࣻ۽ ֍ਵݶ ೧ ੋ
٬ਵ۽ب ߸ജ оמפ