DAILY DOCDAILY DOC
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
  • node

    • NODE
    • parseArgs
    • compose
    • date-format
    • dayjs
    • encrypt
    • env-cmd
    • glob
    • Koa 洋葱模型
    • lodash
    • logger
    • log4js
    • mongod
    • nanoid
    • node-red
    • node-stream
    • node:test
    • nodemailer
    • nodemon
    • nodered
    • parse-curl
    • pm2
    • toml
    • ws
    • yargs
    • zx

node-stream

stream

details
const fs = require('fs');
const rstream = fs.createReadStream('file.json');
rstream.on('data', chunk => {
    //
});
rstream.on('end', () => {});
rstream.on('error', () => {});

readline

details
const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.question('What is your name? ', answer => {
    console.log(`Hello, ${answer}!`);
    rl.close();
});
const fs = require('fs');
const readline = require('readline');

const rl = readline.createInterface({
    input: fs.createReadStream('file.txt'),
    output: process.stdout,
    terminal: false,
});

rl.on('line', line => {
    console.log(`Line from file: ${line}`);
});

rl.on('close', () => {
    console.log('Finished reading file.');
});
Last Updated:
Contributors: rosendo
Prev
node-red
Next
node:test