“Nodejs erstellen Stream” Code-Antworten

Nodejs erstellen Stream

const { Readable } = require("stream")

const readable = Readable.from(["input string"])

readable.on("data", (chunk) => {
  console.log(chunk) // will be called once with `"input string"`
})
North Bear

NODJS: Stream für große Datei

// Use stream: for big file

const fs = require('fs');

const readStream = fs.createReadStream('./doc/custom_button.dart', {encoding: 'utf-8'});    // Create:  createReadStream()
const writeStream = fs.createWriteStream('./doc/get_code.dart')             // Create  createWriteStream()

        // Method 1

// readStream.on('data', (chunkData) => {
//     console.log('----- NEW CHUNK -----');
//     console.log(chunkData);

//     // add code to new file
//     writeStream.write(chunkData);       // Write code
    
// });

        // Method 2:  Use  Pipe for jon method : read and write
readStream.pipe(writeStream);

Sore Sardine

Ähnliche Antworten wie “Nodejs erstellen Stream”

Fragen ähnlich wie “Nodejs erstellen Stream”

Weitere verwandte Antworten zu “Nodejs erstellen Stream” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen