“NodeJS Buat Stream” Kode Jawaban

NodeJS Buat 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: streaming untuk file besar

// 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

Jawaban yang mirip dengan “NodeJS Buat Stream”

Pertanyaan yang mirip dengan “NodeJS Buat Stream”

Lebih banyak jawaban terkait untuk “NodeJS Buat Stream” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya