Node.js ट्यूटोरियल

Node.js होम Node.js परिचय Node.js प्रारंभ करें Node.js मॉड्यूल Node.js HTTP मॉड्यूल Node.js फ़ाइल सिस्टम Node.js URL मॉड्यूल Node.js एनपीएम Node.js घटनाएँ Node.js फ़ाइलें अपलोड करें Node.js ईमेल

Node.js MySQL

MySQL प्रारंभ करें MySQL डेटाबेस बनाएँ MySQL तालिका बनाएँ MySQL सम्मिलित करें MySQL से चुनें MySQL कहाँ MySQL ऑर्डर बाय MySQL हटाएं MySQL ड्रॉप टेबल MySQL अद्यतन MySQL सीमा मायएसक्यूएल जॉइन

Node.js MongoDB

मोंगोडीबी आरंभ करें MongoDB डेटाबेस बनाएँ MongoDB संग्रह बनाएँ मोंगोडीबी डालें मोंगोडीबी खोजें मोंगोडीबी क्वेरी मोंगोडीबी सॉर्ट मोंगोडीबी हटाएं MongoDB ड्रॉप संग्रह मोंगोडीबी अपडेट मोंगोडीबी सीमा मोंगोडीबी शामिल हों

रास्पबेरी पाई

रासपी आरंभ करें रासपी जीपीआईओ परिचय रासपी ब्लिंकिंग एलईडी रासपी एलईडी और पुशबटन रासपी बहने वाली एल ई डी रासपी वेबसाकेट रासपी आरजीबी एलईडी वेबसाकेट रास्पी अवयव

Node.js संदर्भ

अंतर्निहित मॉड्यूल

Node.js स्ट्रीम मॉड्यूल

अंतर्निहित मॉड्यूल


उदाहरण

लिखने योग्य स्ट्रीम में लिखें:

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.write('Hello World!');
  res.end();
}).listen(8080);

परिभाषा और उपयोग

स्ट्रीम मॉड्यूल स्ट्रीमिंग डेटा को संभालने का एक तरीका प्रदान करता है।

धाराएँ दो प्रकार की होती हैं: पठनीय और लिखने योग्य।

पठनीय स्ट्रीम का एक उदाहरण http.createServer() पद्धति के साथ काम करने पर आपको मिलने वाली प्रतिक्रिया वस्तु है।

लिखने योग्य स्ट्रीम का एक उदाहरण अनुरोध ऑब्जेक्ट है जो आपको http.createServer() पद्धति के साथ कार्य करते समय प्राप्त होता है।


वाक्य - विन्यास

कुछ विधियाँ एक पठनीय/लिखने योग्य स्ट्रीम ऑब्जेक्ट लौटाती हैं, जैसे http.createServer(), और यदि ऐसा है, तो आपको स्ट्रीम मॉड्यूल को शामिल करने की आवश्यकता नहीं है।

अन्यथा, आपके एप्लिकेशन में स्ट्रीम मॉड्यूल को शामिल करने के लिए सिंटैक्स:

var stream = require('stream');

पठनीय स्ट्रीम गुण और तरीके

Method Description
isPaused() Returns true if the state of  the readable stream is paused, otherwise false
pause() Pauses the readable stream
pipe() Turns the readable stream into the specified writable stream
read() Returns a specified part of the readable stream
resume() Resumes a paused stream
setEncoding() Sets the character encoding of the readable stream
unpipe() Stops turning a readable stream into a writable stream, caused by the pipe() method
unshift() Pushes some specified data back into the internal buffer
wrap() Helps reading streams made by older Node.js versions

लिखने योग्य स्ट्रीम गुण और तरीके

Method Description
cork() Stops the writable stream and all written data will be buffered in memory
end() Ends the writable stream
setDefaultEncoding() Sets the encoding for the writable stream
uncork() Flushes all data that has been buffered since the cork() method was called
write() Writes data to the stream

अंतर्निहित मॉड्यूल