Open derKuba opened 7 years ago
I'm seeing this as well, using version 0.4.0. Tried to follow the example as given in the documentation.
how can use pause and resume function in the Module? thx~
Same here... Will try to find a workaround. EDIT: solved it this way:
return new Promise((resolve, reject) => {
lineReader.eachLine(file, function lineOperation (line, last, cb) {
doYourThing(line, cb);
}, function finished (err) {
if (err) return reject(err);
resolve();
});
});
I get the same error
TypeError: lineReader.eachLine(...).then is not a function
from https://github.com/wallali/geocoder.js/blob/master/data/build.js I don't know how to fix it.
Also seeing this issue...
import lineReader from 'line-reader';
export const eachLine = (filename, iteratee) => new Promise(((resolve, reject) => {
lineReader.eachLine(filename, iteratee, (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
}));
await eachLine('file.txt', (line) => {
// ...
}
Documentation (README.md) updated on Github but not NPM site.
Reading the documentation now, this is what's recommended:
const lineReader = require("line-reader");
const Promise = require("bluebird");
const eachLine = Promise.promisify(lineReader.eachLine);
eachLine(path, function (line) {
// do your thing
}).then(() => {
// All the lines are read
});
If you're still having issues, node has an inbuilt module that does the same (and can be easily wrapped in a promise) called readline. Example here - https://daendersby.medium.com/stop-using-line-reader-1ad452f68155
If you're still having issues, node has an inbuilt module that does the same (and can be easily wrapped in a promise) called readline. Example here - https://daendersby.medium.com/stop-using-line-reader-1ad452f68155
Reading that article requires subscription. Someone can read it free in the following link: https://stackabuse.com/reading-a-file-line-by-line-in-node-js/
When i try to use this code sample...
... i get this error:
}).then(function (err) { ^ TypeError: lineReader.eachLine(...).then is not a function
Do you have any idea why?