npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-cli-lzy

v1.0.1

Published

simple node fun

Downloads

5

Readme

node - simple - fn


终端模块ttf 控制和用户的 输入输出, 一个输入流 一个输出流,process.stdin process.stdout 分别是这两个的实例


readline的createInterface 是一个实现类,参数 input output pormpt等;传入对应的内容 即可达到方便的控制 每行的输入 监听对应line 事件即可获取,question prompt 等 事件方便用户的交流

  1. 学习node的时候 有几个node的模块 是 需要学习的 本demo 是readlne模块的

一个微型cli

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  prompt: '请输入> '
});

rl.prompt();

rl.on('line', (line) => {
  switch (line.trim()) {
    case 'hello':
      console.log('world!');
      break;
    default:
      console.log(`你输入的是:'${line.trim()}'`);
      break;
  }
  rl.prompt();
}).on('close', () => {
  console.log('再见!');
  process.exit(0);
});
  1. 逐行读取 文本流
const readline = require('readline');
const fs = require('fs');

const rl = readline.createInterface({
  input: fs.createReadStream('sample.txt'),
  crlfDelay: Infinity
});

rl.on('line', (line) => {
  console.log(`文件的每行内容:${line}`);
});
  1. command 是一个高度封装的方便使用的终端交流控制模块

  1. inquirer 是一个 控制用户输入 问题 记录用户问题的一个 高度封装的模块 将需要用户决定的内容 友好的 方式 给用户展示 inquire 可以是 下啦选择 输入 确认等 相当于h5 的form 收集用户的输入 采取下一步的操作
  2. ora 是一个 创建终端 loading toast 等一个工具, 提示给用户一些 信息 ora(..) 返回一个spinner 实例 spinner 上面 有 一些方法,一些属性 ,succeed error text color 等
  3. commander 是一个 在启动的时候 命令行里面 的参数 方便解析的一个 模块
    例如启动的时候 --name=zhangsan --age=18 --color=green 等 都能够方便的解析出来 并且能够通过给的参数 生成--help的 文档内容 常常用于讲命令注册到全局,时候 从启动参数里面 取参数