Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
readline-utils
Advanced tools
Readline utils, for moving the cursor, clearing lines, creating a readline interface, and more.
Readline utils, for moving the cursor, clearing lines, creating a readline interface, and more.
Install with npm:
$ npm install --save readline-utils
var utils = require('readline-utils');
Create a readline interface with the given options
.
Params
options
{Object}Move cursor up by n
lines.
Params
rl
{Readline}: Readline interfacen
{Number}: Lines up to move. Default is 1
.Move cursor down by n
lines.
Params
rl
{Readline}: Readline interfacen
{Number}: Lines down to move. Default is 1
.Move cursor left by n
colums.
Params
rl
{Readline}: Readline interfacen
{Number}: Characters to move left. Default is 1
.Move cursor right by n
colums.
Params
rl
{Readline}: Readline interfacen
{Number}: Characters to move right. Default is 1
.Move cursor up, down, left or right by 1
line.
Params
rl
{Readline}: Readline interfaceExample
var utils = require('readline-utils');
var rl = utils.createInterface();
rl.input.on('keypress', function(str, key) {
utils.move(rl, key);
});
Callback function for the keypress
event, to automatically move cursor up, down, left or right by 1
line.
Params
rl
{Readline}: Readline interfaceExample
var utils = require('readline-utils');
var rl = utils.createInterface();
rl.input.on('keypress', utils.auto(rl));
Clear n
lines after the cursor.
Params
rl
{Readline}: Readline interfacen
{Number}: Number of lines to clearClear the terminal.
Params
rl
{Readline}: Readline interfacen
{Number}: Number of lines to clearGet the last line from the given str
Params
str
{String}returns
{String}Get the height (rows) of the given str
Params
str
{String}returns
{Number}Hide the cursor so it doesn't show during a prompt. This is useful for multiple-choice or list prompts, or any prompt where the user will not be entering input.
Params
rl
{Readline}: Readline interfacereturns
{Object}: readline-utils object for chainingShow the cursor.
Params
rl
{Readline}: Readline interfacereturns
{Object}: readline-utils object for chainingClose the interface, remove event listeners, and restore/unmute prompt functionality
Params
rl
{Readline}: Readline interfacereturns
{Object}: readline-utils object for chainingClose the interface when the keypress is ^C
Params
rl
{Readline}: Readline interfacereturns
{Object}: readline-utils object for chainingErase n
lines
Params
n
{Number}returns
{String}: Returns the unicode to erase linesExample
utils.eraseLines(3);
Remove lines from the bottom of the terminal.
Params
rl
{Number}: Readline interfacelines
{Number}: Number of lines to removeheight
{Number}: Content heightreturns
{Object}: Returns the readline-utils object for chainingRemember the cursor position
returns
{Object}: readline-utils objectRestore the cursor position to where it has been previously stored.
returns
{Object}: readline-utils objectGet the width of the terminal
returns
{Number}: Returns the number of columns.Break lines longer than the cli width so we can normalize the natural line returns behavior accross terminals. (I don't see how this can work consistently. It seems brittle and will probably be replaced with https://github.com/jonschlinkert/word-wrap)
Params
lines
{Array}: Array of lineswidth
{Number}: Terminal widthJoins the lines returned from .breakLines.
Params
lines
{Array|String}: String or array of lines.width
{Number}: Terminal widthreturns
{String}Ensure the given str
ends in a newline.
Params
str
{String}: The input stringreturns
{String}Example
console.log(utils.normalizeLF('foo'));
//=> 'foo\n'
This module offers the internal "keypress" functionality from node-core's readline
module, for your own programs and modules to use.
The keypress
function accepts a readable Stream instance and makes it
emit "keypress" events.
Usage:
Params
Example
require('keypress')(process.stdin);
process.stdin.on('keypress', function(ch, key) {
console.log(ch, key);
if (key.ctrl && key.name === 'c') {
process.stdin.pause();
}
});
proces.stdin.resume();
Enables "mousepress" events on the input stream. Note
that stream
must be an output stream (i.e. a Writable
Stream instance), usually process.stdout
.
Params
Disables "mousepress" events from being sent to the input
stream. Note that stream
must be an output stream (i.e.
a Writable Stream instance), usually process.stdout
.
Params
Some of this code was initially borrowed from [Inquirer][].
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
Commits | Contributor |
---|---|
41 | jonschlinkert |
7 | doowb |
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on May 21, 2017.
FAQs
Readline utils, for moving the cursor, clearing lines, creating a readline interface, and more.
The npm package readline-utils receives a total of 31,975 weekly downloads. As such, readline-utils popularity was classified as popular.
We found that readline-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.