THE_DEVELOPER_GUIDE Telegram 5743
ุฏุฑุฏุดุฉ ุณุฑูŠุนุฉ ุนู† ุงู„ู€ Buffer ููŠ Node.js ๐Ÿ’ฏ
.
.
ุฃุบู„ุจ ุงู„ูˆู‚ุช ูˆุฅุญู†ุง ุจู†ูƒุชุจ ูƒูˆุฏ ููŠ Node.jsุŒ ุจู†ุชุนุงู…ู„ ู…ุน ุงู„ุจูŠุงู†ุงุช ุงู„ู„ูŠ ุฑุงุฌุนู‡ ู…ู† ุงู„ู€ APIs ุฃูˆ ู…ู† ุงู„ู€ Database ุฃูˆ ู…ู† ุงู„ู€ Files ุนู„ู‰ ู‡ูŠุฆุฉ Strings ุฃูˆ JSON. ุชู…ุงู… ูƒุฏู‡ุŸ ู„ูƒู†ุŒ ู„ูˆ ู‡ู†ุชุนุงู…ู„ ู…ุน ุญุงุฌุงุช ุฒูŠ ุงู„ุตูˆุฑุŒ ุงู„ู…ู„ูุงุช ุงู„ุตูˆุชูŠุฉุŒ ุงู„ููŠุฏูŠูˆุŒ ุฃูˆ ุฃูŠ Data ุบูŠุฑ ู†ุตูŠู‘ุฉ (non-text)ุŒ ูˆู‚ุชู‡ุง ุงู„ู€ JavaScript ู…ุง ุชุนุฑู ุชุชุนุงู…ู„ ู…ุน ุงู„ู†ูˆุน ุฏู‡ ุจุดูƒู„ ู…ุจุงุดุฑ. ูˆู‡ู†ุง ูŠูŠุฌูŠ ุฏูˆุฑ ุงู„ู€ Buffer.

โ€”โ€”โ€”

๐Ÿ“Œ ุฅูŠู‡ ู‡ูˆ ุงู„ู€ BufferุŸ

ุงู„ู€ Buffer ู‡ูˆ ุจุจุณุงุทุฉ ุทุฑูŠู‚ุฉ Node.js ู„ู„ุชุนุงู…ู„ ู…ุน ุงู„ุจูŠุงู†ุงุช ุงู„ุฎุงู… (Raw Binary Data) ุงู„ู„ูŠ ุฑุงุฌุนุฉ ู…ู† ุฃูˆ ุฑุงูŠุญุฉ ู„ู…ุตุฏุฑ ุฎุงุฑุฌูŠุŒ ุฒูŠ ู…ุซู„ู‹ุง File System ุฃูˆ TCP StreamุŒ ุฃูˆ ุญุชู‰ ู…ู† HTTP Response.

ูŠุนู†ูŠ ู„ูˆ ุนู†ุฏูƒ ูุงูŠู„ MP3ุŒ ุฃู†ุช ู…ุด ู‡ุชู‚ุฑุฃู‡ ูƒู€ "ู†ุต"ุŒ ุฃู†ุช ู‡ุชู‚ุฑุฃู‡ ูƒู€ ุณู„ุณู„ุฉ ู…ู† ุงู„ุฃุฑู‚ุงู… (bytes). ูˆุงู„ู€ Buffer ุจูŠุณู…ุญู„ูƒ ุชู…ุณูƒ ุงู„ุณู„ุณู„ุฉ ุฏูŠุŒ ูˆุชุชุนุงู…ู„ ู…ุนุงู‡ุง ููŠ ุงู„ุฐุงูƒุฑุฉ.

โ€”โ€”โ€”

๐Ÿ“ฆ ู„ูŠู‡ Node.js ุจุชุณุชุฎุฏู… BuffersุŸ

ุนู„ุดุงู† Node.js ู…ุจู†ูŠุฉ ุญูˆู„ ุงู„ู€ Streams. ูˆุงู„ู€ Streams ููŠ ุงู„ุบุงู„ุจ ู…ุด ุจุชุฏูŠู„ูƒ ุงู„ุจูŠุงู†ุงุช ูƒู„ู‡ุง ู…ุฑุฉ ูˆุงุญุฏุฉุŒ ุจุชุจุนุชู‡ุง ู„ูƒ ุฌุฒุก ุฌุฒุก.

ู…ุซุงู„ ุจุณูŠุท:
ู„ูˆ ุจุชู‚ุฑุฃ ูุงูŠู„ ูƒุจูŠุฑ ู…ู† ุนู„ู‰ ุงู„ู‡ุงุฑุฏุŒ ุงู„ู€ Node.js ู…ุด ู‡ุชุญู…ู‘ู„ ุงู„ูุงูŠู„ ูƒู„ู‡ ููŠ RAM ู…ุฑุฉ ูˆุงุญุฏุฉ (ุนุดุงู† ุฏู‡ ู…ุด ุนู…ู„ูŠ ูˆู…ู…ูƒู† ูŠู…ูˆุช ุงู„ุณูŠุณุชู… ู„ูˆ ุงู„ูุงูŠู„ ูƒุจูŠุฑ ุฌุฏู‹ุง)ุŒ ู‡ูŠ ุจุชู‚ุฑุฃ Chunk ุจู€ Chunk. ูƒู„ Chunk ู…ู† ุฏูˆู„ ู‡ูˆ ุนุจุงุฑุฉ ุนู† Buffer.

โ€”โ€”โ€”

๐Ÿ’ก ู…ุซุงู„ ุนู…ู„ูŠ

const fs = require('fs');

const readableStream = fs.createReadStream('video.mp4');

readableStream.on('data', (chunk) => {
  console.log('Received chunk:', chunk);
  console.log('Chunk is a buffer?',   

  Buffer.isBuffer(chunk)); // true
});

ููŠ ุงู„ู…ุซุงู„ ุฏู‡ุŒ ูƒู„ ู…ุฑุฉ ุงู„ู€ Stream ุจูŠุจุนุช DataุŒ ุจู†ุณุชู‚ุจู„ู‡ุง ุนู„ู‰ ู‡ูŠุฆุฉ Buffer. ุชู‚ุฏุฑ ุชุชุนุงู…ู„ ู…ุนุงู‡ุงุŒ ุชุฎุฒู†ู‡ุงุŒ ุชุจุนุชู‡ุงุŒ ุฃูˆ ุญุชู‰ ุชุนุฏู‘ู„ ููŠู‡ุง.

โ€”โ€”โ€”

โœจ ุดูˆูŠุฉ ุญุงุฌุงุช ู…ู‡ู…ุฉ ุนู† Buffer:

- ุงู„ู€ Buffer.from: ุจูŠุญูˆู‘ู„ ุฃูŠ String ุฃูˆ Array ุฃูˆ ุญุชู‰ ArrayBuffer ู„ู€ Buffer.
- ุงู„ู€ Buffer.alloc(size): ุจูŠุนู…ู„ Buffer ูุงุถูŠ ุจุงู„ุญุฌู… ุงู„ู„ูŠ ุชุญุฏุฏู‡.
- ุงู„ู€ buffer.toString: ู„ูˆ ุนุงูŠุฒ ุชุฑุฌู‘ุน ุงู„ู€ Buffer ู„ุตูŠุบุฉ String (ู„ูˆ ุฃุตู„ู‹ุง ูƒุงู†ุช Text).

โ€”โ€”โ€”

ู„ุงุฒู… ุชูƒูˆู† ูุงู‡ู… ูŠุนู†ูŠ ุฅูŠู‡ Buffer ููŠ ุงู„ุญุงู„ุงุช ุฏูŠ:

- ู„ูˆ ุจุชุชุนุงู…ู„ ู…ุน ุงู„ู…ู„ูุงุช ุงู„ูƒุจูŠุฑุฉ.
- ู„ูˆ ุดุบุงู„ ุนู„ู‰ ุชุทุจูŠู‚ ุจูŠุณุชู‚ุจู„ ุตูˆุฑ ุฃูˆ ููŠุฏูŠูˆู‡ุงุช ุฃูˆ ุฃุตูˆุงุช.
- ู„ูˆ ุดุบุงู„ ู…ุน Streams (ุฒูŠ HTTP Requests ุฃูˆ TCP Connections).
- ู„ูˆ ุจุชุจุนุช ุฃูˆ ุจุชุณุชู‚ุจู„ Binary Data ู…ู† API ุฃูˆ ุฌู‡ุงุฒ ุชุงู†ูŠ.

โ€”โ€”โ€”

ุงู„ู€ Buffers ุจุชุดุชุบู„ ุนู„ู‰ ู…ุณุชูˆู‰ ุงู„ู€ Memory ู…ุจุงุดุฑุฉุŒ ูŠุนู†ูŠ ู„ูˆ ู…ุนุฑูุชุด ุชุชุนุงู…ู„ ู…ุนุงู‡ู… ุตุญุŒ ู…ู…ูƒู† ุชู‚ุน ููŠ ู…ุดุงูƒู„ ุฒูŠ memory leaks ุฃูˆ inefficient data handling.

โ€”โ€”โ€”

ูˆูู‚ูƒู… ุงู„ู„ู‡ ู„ูƒู„ ุฎูŠุฑ ๐ŸŒฟ
โค5



tgoop.com/the_developer_guide/5743
Create:
Last Update:

ุฏุฑุฏุดุฉ ุณุฑูŠุนุฉ ุนู† ุงู„ู€ Buffer ููŠ Node.js ๐Ÿ’ฏ
.
.
ุฃุบู„ุจ ุงู„ูˆู‚ุช ูˆุฅุญู†ุง ุจู†ูƒุชุจ ูƒูˆุฏ ููŠ Node.jsุŒ ุจู†ุชุนุงู…ู„ ู…ุน ุงู„ุจูŠุงู†ุงุช ุงู„ู„ูŠ ุฑุงุฌุนู‡ ู…ู† ุงู„ู€ APIs ุฃูˆ ู…ู† ุงู„ู€ Database ุฃูˆ ู…ู† ุงู„ู€ Files ุนู„ู‰ ู‡ูŠุฆุฉ Strings ุฃูˆ JSON. ุชู…ุงู… ูƒุฏู‡ุŸ ู„ูƒู†ุŒ ู„ูˆ ู‡ู†ุชุนุงู…ู„ ู…ุน ุญุงุฌุงุช ุฒูŠ ุงู„ุตูˆุฑุŒ ุงู„ู…ู„ูุงุช ุงู„ุตูˆุชูŠุฉุŒ ุงู„ููŠุฏูŠูˆุŒ ุฃูˆ ุฃูŠ Data ุบูŠุฑ ู†ุตูŠู‘ุฉ (non-text)ุŒ ูˆู‚ุชู‡ุง ุงู„ู€ JavaScript ู…ุง ุชุนุฑู ุชุชุนุงู…ู„ ู…ุน ุงู„ู†ูˆุน ุฏู‡ ุจุดูƒู„ ู…ุจุงุดุฑ. ูˆู‡ู†ุง ูŠูŠุฌูŠ ุฏูˆุฑ ุงู„ู€ Buffer.

โ€”โ€”โ€”

๐Ÿ“Œ ุฅูŠู‡ ู‡ูˆ ุงู„ู€ BufferุŸ

ุงู„ู€ Buffer ู‡ูˆ ุจุจุณุงุทุฉ ุทุฑูŠู‚ุฉ Node.js ู„ู„ุชุนุงู…ู„ ู…ุน ุงู„ุจูŠุงู†ุงุช ุงู„ุฎุงู… (Raw Binary Data) ุงู„ู„ูŠ ุฑุงุฌุนุฉ ู…ู† ุฃูˆ ุฑุงูŠุญุฉ ู„ู…ุตุฏุฑ ุฎุงุฑุฌูŠุŒ ุฒูŠ ู…ุซู„ู‹ุง File System ุฃูˆ TCP StreamุŒ ุฃูˆ ุญุชู‰ ู…ู† HTTP Response.

ูŠุนู†ูŠ ู„ูˆ ุนู†ุฏูƒ ูุงูŠู„ MP3ุŒ ุฃู†ุช ู…ุด ู‡ุชู‚ุฑุฃู‡ ูƒู€ "ู†ุต"ุŒ ุฃู†ุช ู‡ุชู‚ุฑุฃู‡ ูƒู€ ุณู„ุณู„ุฉ ู…ู† ุงู„ุฃุฑู‚ุงู… (bytes). ูˆุงู„ู€ Buffer ุจูŠุณู…ุญู„ูƒ ุชู…ุณูƒ ุงู„ุณู„ุณู„ุฉ ุฏูŠุŒ ูˆุชุชุนุงู…ู„ ู…ุนุงู‡ุง ููŠ ุงู„ุฐุงูƒุฑุฉ.

โ€”โ€”โ€”

๐Ÿ“ฆ ู„ูŠู‡ Node.js ุจุชุณุชุฎุฏู… BuffersุŸ

ุนู„ุดุงู† Node.js ู…ุจู†ูŠุฉ ุญูˆู„ ุงู„ู€ Streams. ูˆุงู„ู€ Streams ููŠ ุงู„ุบุงู„ุจ ู…ุด ุจุชุฏูŠู„ูƒ ุงู„ุจูŠุงู†ุงุช ูƒู„ู‡ุง ู…ุฑุฉ ูˆุงุญุฏุฉุŒ ุจุชุจุนุชู‡ุง ู„ูƒ ุฌุฒุก ุฌุฒุก.

ู…ุซุงู„ ุจุณูŠุท:
ู„ูˆ ุจุชู‚ุฑุฃ ูุงูŠู„ ูƒุจูŠุฑ ู…ู† ุนู„ู‰ ุงู„ู‡ุงุฑุฏุŒ ุงู„ู€ Node.js ู…ุด ู‡ุชุญู…ู‘ู„ ุงู„ูุงูŠู„ ูƒู„ู‡ ููŠ RAM ู…ุฑุฉ ูˆุงุญุฏุฉ (ุนุดุงู† ุฏู‡ ู…ุด ุนู…ู„ูŠ ูˆู…ู…ูƒู† ูŠู…ูˆุช ุงู„ุณูŠุณุชู… ู„ูˆ ุงู„ูุงูŠู„ ูƒุจูŠุฑ ุฌุฏู‹ุง)ุŒ ู‡ูŠ ุจุชู‚ุฑุฃ Chunk ุจู€ Chunk. ูƒู„ Chunk ู…ู† ุฏูˆู„ ู‡ูˆ ุนุจุงุฑุฉ ุนู† Buffer.

โ€”โ€”โ€”

๐Ÿ’ก ู…ุซุงู„ ุนู…ู„ูŠ

const fs = require('fs');

const readableStream = fs.createReadStream('video.mp4');

readableStream.on('data', (chunk) => {
  console.log('Received chunk:', chunk);
  console.log('Chunk is a buffer?',   

  Buffer.isBuffer(chunk)); // true
});

ููŠ ุงู„ู…ุซุงู„ ุฏู‡ุŒ ูƒู„ ู…ุฑุฉ ุงู„ู€ Stream ุจูŠุจุนุช DataุŒ ุจู†ุณุชู‚ุจู„ู‡ุง ุนู„ู‰ ู‡ูŠุฆุฉ Buffer. ุชู‚ุฏุฑ ุชุชุนุงู…ู„ ู…ุนุงู‡ุงุŒ ุชุฎุฒู†ู‡ุงุŒ ุชุจุนุชู‡ุงุŒ ุฃูˆ ุญุชู‰ ุชุนุฏู‘ู„ ููŠู‡ุง.

โ€”โ€”โ€”

โœจ ุดูˆูŠุฉ ุญุงุฌุงุช ู…ู‡ู…ุฉ ุนู† Buffer:

- ุงู„ู€ Buffer.from: ุจูŠุญูˆู‘ู„ ุฃูŠ String ุฃูˆ Array ุฃูˆ ุญุชู‰ ArrayBuffer ู„ู€ Buffer.
- ุงู„ู€ Buffer.alloc(size): ุจูŠุนู…ู„ Buffer ูุงุถูŠ ุจุงู„ุญุฌู… ุงู„ู„ูŠ ุชุญุฏุฏู‡.
- ุงู„ู€ buffer.toString: ู„ูˆ ุนุงูŠุฒ ุชุฑุฌู‘ุน ุงู„ู€ Buffer ู„ุตูŠุบุฉ String (ู„ูˆ ุฃุตู„ู‹ุง ูƒุงู†ุช Text).

โ€”โ€”โ€”

ู„ุงุฒู… ุชูƒูˆู† ูุงู‡ู… ูŠุนู†ูŠ ุฅูŠู‡ Buffer ููŠ ุงู„ุญุงู„ุงุช ุฏูŠ:

- ู„ูˆ ุจุชุชุนุงู…ู„ ู…ุน ุงู„ู…ู„ูุงุช ุงู„ูƒุจูŠุฑุฉ.
- ู„ูˆ ุดุบุงู„ ุนู„ู‰ ุชุทุจูŠู‚ ุจูŠุณุชู‚ุจู„ ุตูˆุฑ ุฃูˆ ููŠุฏูŠูˆู‡ุงุช ุฃูˆ ุฃุตูˆุงุช.
- ู„ูˆ ุดุบุงู„ ู…ุน Streams (ุฒูŠ HTTP Requests ุฃูˆ TCP Connections).
- ู„ูˆ ุจุชุจุนุช ุฃูˆ ุจุชุณุชู‚ุจู„ Binary Data ู…ู† API ุฃูˆ ุฌู‡ุงุฒ ุชุงู†ูŠ.

โ€”โ€”โ€”

ุงู„ู€ Buffers ุจุชุดุชุบู„ ุนู„ู‰ ู…ุณุชูˆู‰ ุงู„ู€ Memory ู…ุจุงุดุฑุฉุŒ ูŠุนู†ูŠ ู„ูˆ ู…ุนุฑูุชุด ุชุชุนุงู…ู„ ู…ุนุงู‡ู… ุตุญุŒ ู…ู…ูƒู† ุชู‚ุน ููŠ ู…ุดุงูƒู„ ุฒูŠ memory leaks ุฃูˆ inefficient data handling.

โ€”โ€”โ€”

ูˆูู‚ูƒู… ุงู„ู„ู‡ ู„ูƒู„ ุฎูŠุฑ ๐ŸŒฟ

BY DevGuide ๐Ÿ‡ต๐Ÿ‡ธ


Share with your friend now:
tgoop.com/the_developer_guide/5743

View MORE
Open in Telegram


Telegram News

Date: |

Matt Hussey, editorial director at NEAR Protocol also responded to this news with โ€œ#meIRLโ€. Just as you search โ€œBear Market Screamingโ€ in Telegram, you will see a Pepe frog yelling as the groupโ€™s featured image. The public channel had more than 109,000 subscribers, Judge Hui said. Ng had the power to remove or amend the messages in the channel, but he โ€œallowed them to exist.โ€ The group also hosted discussions on committing arson, Judge Hui said, including setting roadblocks on fire, hurling petrol bombs at police stations and teaching people to make such weapons. The conversation linked to arson went on for two to three months, Hui said. To delete a channel with over 1,000 subscribers, you need to contact user support While some crypto traders move toward screaming as a coping mechanism, many mental health experts have argued that โ€œscream therapyโ€ is pseudoscience. Scientific research or no, it obviously feels good.
from us


Telegram DevGuide ๐Ÿ‡ต๐Ÿ‡ธ
FROM American