
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
readline-promises
Advanced tools
Console readline with promise
Module to read console lines in a simple way and with promises
npm install --save readline-promises
Readline
// Import
const ReadLine = require('readline-promises');
// Object
const Read = new ReadLine();
// Send Question
Read.Question('What\'s your name?')
.then((name) => {
console.log(`Hello ${name}`);
})
.catch(console.error); // Error handler
Options
// Import
const ReadLine = require('readline-promises');
// Object
const Read = new ReadLine();
// Options
const options = [
'windows',
'linux',
'mac os',
];
// Send Question
Read.Options('What\'s your favorite os?', options)
.then((name) => {
console.log(`Your select: ${name}`);
})
.catch(console.error); // Error handler
Option [y/n]
// Import
const ReadLine = require('readline-promises');
// Object
const Read = new ReadLine();
// Send Question
Read.KeyYN('Do you like this module?')
.then((result) => {
const print = result ? 'Nice! :)' : 'Oh, :(';
console.log(print);
})
.catch(console.error); // Error handler
Concat questions
// Import
const ReadLine = require('readline-promises');
// Options
const options = {
concat: true,
};
// Object
const Read = new ReadLine(options);
// Send Question
Read.Question('What\'s your name?', 'name')
.then(Read.Question('What\'s your lastname?', 'lastname'))
.then((data) => {
console.log(`Hello ${data.name} ${data.lastname}`);
})
.catch(console.error); // Error handler
Concat all methods
// Import
const ReadLine = require('readline-promises');
// Configs
const options = {
concat: true,
};
const osOptions = [
'windows',
'linux',
'mac os',
];
// Object
const Read = new ReadLine(options);
// Send Question
Read.Question('What\'s your name? ', 'name')
.then(Read.Options('What\'s your favorite os? ', osOptions, 'os'))
.then(Read.KeyYN('Do you like this module? ', 'like'))
.then((data) => {
// Get info
const { name, os, like } = data;
const youLike = !like ? 'not ' : '';
// Print all info
console.log(`Your name: ${name}`);
console.log(`Your favorite os: ${os}`);
console.log(`You do ${youLike}like this module`);
})
.catch(console.error); // Error handler
FAQs
Console readline with promise
The npm package readline-promises receives a total of 5 weekly downloads. As such, readline-promises popularity was classified as not popular.
We found that readline-promises demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.