line-current
v1.0.0
Published
Get current line in terminal at any time
Downloads
16
Maintainers
Readme
Line-current module
Description
You can use this module to get the current line of the terminal in a pretty short time
Installation
npm install line-current
Usage (Normal)
var linecurrent = require("line-current");
var app = async function(){
var currentLine = await linecurrent.get();
//Put your code here
//
//Printing current line to terminal
console.log(currentLine);
//Printing confirmation message to terminal
console.log("It's working!");
//Lets get it again:
currentLine = await linecurrent.get();
//Printing current line to terminal
console.log(currentLine);
//Printing confirmation message to terminal
console.log("It's still working!");
}
app();
//If you put code here everything will fall appart
//
Will return:
{"processtime":%time it took to get current line%,"current-line":%current line%}
It's working!
{"processtime":%time it took to get current line%,"current-line":%current line%}
It's still working!
Usage (Formatted)
var linecurrent = require("line-current");
var app = async function(){
var currentLine = await linecurrent.get(true);
//Put your code here
//
//Printing current line to terminal
console.log(currentLine);
//Printing confirmation message to terminal
console.log("It's working!");
//Lets get it again:
currentLine = await linecurrent.get(true);
//Printing current line to terminal
console.log(currentLine);
//Printing confirmation message to terminal
console.log("It's still working!");
}
app();
//If you put code here everything will fall appart
//
Will return:
{
"processtime": %time it took to get current line%,
"current-line": %current line%
}
It's working!
{
"processtime": %time it took to get current line%,
"current-line": %current line%
}
It's still working!
Syntax
await linecurrent.get(%formatted?%);
Output exemple (normal)
{"current-line":1,"processtime":"143ms"}
Output exemple (formatted)
{
"current-line": 1,
"processtime": "143ms"
}
Details
Output are json as string, you can parse it with JSON.parse() if you want to use it as an object, to run the get command you need to use it with await in a async function in the exemples it was app else everything will fall appart.
How does it work
This module uses the ainsi escape code on the current line process the output revert the terminal to before that and returns the output as formatted or not depending on function args.
Creator
It's me willmil11 :)