Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get lines as list from file node js

const fs = require('fs');

fs.readFile('file.txt', function(err, data) {
    if(err) throw err;

    const arr = data.toString().replace(/
/g,'
').split('
');

    for(let i of arr) {
        console.log(i);
    }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: UnhandledPromiseRejectionWarning: Error: Node is either not clickable or not an HTMLElement 
Javascript :: react router how to go back 
Javascript :: fullscreen electron 
Javascript :: set default version of node nvm 
Javascript :: change favicon with javascript 
Javascript :: javascript replace  
Javascript :: adding event on enter key keypress in javascript 
Javascript :: Regex port number 
Javascript :: error java.io.filenotfoundexception tessdata/eng.traineddata 
Javascript :: conditionally add a property to an object 
Javascript :: keyboard arrow event handling javascript 
Javascript :: fetch await 
Javascript :: generate random number nodejs 
Javascript :: jquery transform scale 
Javascript :: javascript Convert an array of strings to numbers 
Javascript :: jquery get base url 
Javascript :: remove hidden attribute in js 
Javascript :: import path in ES6 module 
Javascript :: TypeError: Promise resolver undefined is not a function 
Javascript :: credit card regex javascript 
Javascript :: js strip_tags 
Javascript :: how to do text to speech in javascript 
Javascript :: vuejs cdn 
Javascript :: mongodb add user 
Javascript :: js how to get selectpicker value 
Javascript :: get device type javascript 
Javascript :: replacing characters in string javascript 
Javascript :: convert to small case in javascript 
Javascript :: install node js lts ubuntu 18.04 
Javascript :: nextjs tailwind 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =