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

simple-steps

v0.1.2

Published

Help you output the step log in the terminal, and count the time spent.

Downloads

2

Readme

simple-steps

version downloads

Help you output the step log in the terminal, and count the time spent. 帮助你在终端输出步骤日志,和计算所花费的时间。

preview

起步

安装

npm install --save-dev simple-steps

用法

const Steps = require('simple-steps').Steps;

let steps = new Steps({ stepTotal: 2 });
try {
    steps.step('clear').start();
    // 做些事情
    steps.last.succeed();
} catch (e) {
    steps.fail();
    return;
}
try {
    steps.step('build').start();
    // 做些事情
    steps.last.succeed();
} catch (e) {
    steps.fail();
    return;
}
steps.succeed();

API

const steps = new Steps(options?: StepsOptions);
const step = steps.step('title').start();

StepsOptions

实例化 Steps 的选项。

StepsOptions.stream

类型: NodeJS.WriteStream 默认: process.stdout 设置输出使用的写入流。

StepsOptions.duration

类型: boolean 默认: true 是否输出花费时间。

StepsOptions.splitLine

类型: false | number 默认: 128 是否输出分割线,并指定最大长度。

StepsOptions.stepTotal

类型: false | number 默认: false 是否输出步骤总数,并指定数量。

StepsOptions.handleStepWhenStepsSucceed

类型: boolean 默认: false 当调用 steps.succeed() 时,是否自动调用所有步骤的 step.succeed()

StepsOptions.handleStepWhenStepsFail

类型: boolean 默认: true 当调用 steps.fail() 时,是否自动调用所有步骤的 step.fail()


Class Steps

主要入口。

steps.isStarted: boolean

获取是否正在计时。

steps.stepList: Step[]

获取所有步骤。

steps.last: Step

获取最后一个步骤。

steps.duration: number

获取花费时间,单位 ms。

steps.step(title?: string): Step

title: 设置步骤的标题 创建新的步骤实例。第一次调用时,Steps 将开始计时。

steps.stop()

停止计时。

steps.succeed(handleStep?: boolean)

handleStep: 参考 输出成功消息。

steps.fail(handleStep?: boolean)

handleStep: 参考 输出失败消息。


Class Step

使用 steps.step() 创建的步骤实例。

step.state: StepState

StepState: 'initial' | 'start' | 'stop' | 'succeed' | 'fail' 获取步骤的状态。

step.index: number

获取步骤的索引。(创建顺序)

step.duration: number

获取花费时间,单位 ms。

step.isComplete: boolean

获取步骤是否已经完成。

step.start(): this

输出开始信息,并开始计时。

step.stop()

停止计时。

step.succeed(title?: string)

title: 设置输出的标题 输出成功信息。

step.fail(title?: string)

title: 设置输出的标题 输出失败信息。

License

MIT