read-lines-riched
Advanced tools
Comparing version 0.1.0 to 0.1.2
{ | ||
"name": "read-lines-riched", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "Easy way to read lines of files. You can read lines from start to end of file or from end to start of file.", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
# Read Lines Riched | ||
Easy way to read files line by line on two directions: from the beginning to the last and from the last to beginning. | ||
Easy way to read file lines on two directions: from the beginning to the end and from the end to the beginning. | ||
@@ -17,19 +17,43 @@ ## Installing | ||
## Usage | ||
## Usage with Promise | ||
To use the module. | ||
Reading lines example from the end of the file to the beginning. | ||
``` | ||
const {readLinesStartToEnd, readLinesEndToStart} = require('read-lines-riched'); | ||
const {readLinesEndToStart} = require("read-lines-riched"); | ||
let endToStartRL = readLinesEndToStart("./testing_file"); | ||
var func = function () { | ||
endToStartRL.readNextLine().then(line => { | ||
if (line) { | ||
console.log(line); | ||
func() | ||
} | ||
else | ||
endToStartRL.closeReader(); | ||
}); | ||
}; | ||
func(); | ||
``` | ||
## Usage with Async Await | ||
To read lines from the begining of the file to the end. | ||
Reading lines example from the beginning of the file to the end. | ||
``` | ||
const startToEndRL = readLinesStartToEnd(file_path); | ||
const line = await startToEndRL.readNextLine(); | ||
const { readLinesStartToEnd} = require("read-lines-riched"); | ||
const startToEndRL = readLinesStartToEnd("./testing_file"); | ||
(async function(){ | ||
var line = await startToEndRL.readNextLine(); | ||
while(line) | ||
{ | ||
console.log(line); | ||
line = await startToEndRL.readNextLine(); | ||
} | ||
startToEndRL.closeReader(); | ||
})(); | ||
``` | ||
To read lines from the end of the file to the beginning. | ||
``` | ||
let endToStartRL = readLinesEndToStart(file_path); | ||
const line = await endToStartRL.readNextLine(); | ||
``` | ||
@@ -36,0 +60,0 @@ ## Contributing |
12171
73