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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sam-terminal

v0.0.3-rc.2

Published

A web terminal controller to improve the user experience of entering commands

Readme


sam-terminal

sam-terminal是一个网页命令控制器。
它期望通过命令交互来提高业务使用体验。

sam-terminal低命令概念的一个实现。
低命令的理念是命令高效驱动业务。

Getting Started 使用指南

Prerequisites 项目使用条件

Chrome >= 66
Node.js >= 10.x

Installation 安装

npm i sam-terminal --save

API讲解

import terminal, { parseLowcommand } from 'sam-terminal';

const cmd = new terminal({
  cmdList: [
    {
      cmdName: '命令名', argList: [{ argName: '参数名', list:['参数值1','参数值2'] }],
    }
  ],
  zIndex: 999,
  className: 'helloLowCommand',
  cb({ cmd, ref }) {
    console.log('解析结果', parseLowcommand(cmd));
    console.log('terminal引用', ref);
  }
});

cmd.genDom({
  appendToSelector: 'body'
});

cmd.show();

cmd.hide();

上述代码中,我们从sam-terminal引入了terminal类和parseLowcommand方法。
terminal类的构造函数入参有cmdListcbzIndexclassName
cmdList是一个对象数组。它采用LCS(最长公共子序列)算法实时匹配用户的输入。
其中,数组项对象的cmdName是命令名称,argList是命令对应的参数对象数组。
argList数组项对象的argName是参数名称,list则是参数候选值。

cb是一个回调函数。是用户回车Enter之后调用的函数。
其注入的参数是一个对象,包含两个字段cmdref
cmd是一个字符串,即用户输入的字符串。
ref是一个自带的jQuery对象,即terminal类实例生成的命令输入控制器。

zIndex属性用来指定命令输入控制器的层级。通常用来防止被页面UI库的遮罩层给覆盖掉。
className属性用来指定命令输入控制器的class名称。名称需要唯一性。

terminal类的实例有三个常用方法genDomshowhide
genDom方法用来生成命令输入控制器的dom,并通过参数appendToSelector把命令输入控制器的dom插入css选择器指定的位置。
show方法顾名思义显示命令输入控制器。
hide方法则与show相反,隐藏命令输入控制器。

Usage example 使用示例

参考项目demo的文件demo\src\pages\index.tsx

License 授权协议

这个项目 MIT 协议, 请点击 LICENSE.md 了解更多细节。