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

@imnull/termkit

v1.0.0

Published

基于`NodeJS`的`CLI`工具。

Downloads

2

Readme

@imnull/termkit

基于NodeJSCLI工具。

ColorText 着色

colors

import { colors } from '@imnull/termkit'

// 输出黄色文字
console.log(colors.yellow(' abc '))
// 输出带背景色文字
console.log(colors.blue(' abc ', { background: 'brightBlue' }))

ColorText

import { ColorText } from '@imnull/termkit'

const txt = new ColorText({
    color: 'red',
    background: 'brightBlack',
    bold: true,
})

// 内部调用`console.log`输出
txt.log(' xyz ')
// 作为模版渲染文字
console.log(txt.render(' abc '))

TextFrames 文本帧

目的是为了在CLI中显示文本动画。定义抽象基类TextFrames,包含了通用操作和渲染方法。

TextFrames内部包含一个文本序列,用于实现帧动画效果。每次渲染时,内部索引会向前步进,循环渲染则会出现动画效果。

继承TextFrames,实现了RollingFramesDotsFrames

RollingFrames

实现类似npm安装过程的6点字符旋转。

export class RollingFrames extends TextFrames {
    constructor() {
        super(['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'])
    }
}

DotsFrames

实现3个点横滚效果。

export class DotsFrames extends TextFrames {
    constructor() {
        super(['   ', '.  ', '.. ', '...', ' ..', '  .'])
    }
}

Progress 进度条

进度条,模拟npm安装过程的进度展示。

import { Progress } from '@imnull/termkit'

const progress = new Progress()
console.log(progress.render(0.75))
[#############⠂⠂⠂⠂⠂]

TermFlasher 单行更新

CLI输出内容前,会先清除上一次输出内容,防止终端过多输出内容。

import { TermFlasher } from '@imnull/termkit'

const term = new TermFlasher()
const max = 50
let index = 0;
const interval = setInterval(() => {
    term.log(`${index} / ${max}`);
    index += 1
    if (index > max) {
        clearInterval(interval)
        term.reset()
    }
}, 100);

TermFlasher.log(msg: string)

输出内容。

TermFlasher.reset()

清理输出,重置光标,清空历史记录。

Demo

Demo