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

pomelo-toolbox

v1.2.5

Published

daily node utils.

Downloads

43

Readme

pomelo-toolbox

daily node utils.

features

  • prettier command line
  • json tools
  • ssh tools
  • logger & loading
    const {cmd} = require('pomelo-toolbox');

API

cmd.exec

  • 参数

| param | type | description | |:---:|:---:|:---:| | cmd | String | 命令 | | opt | Object | exec options for child_process |

  • 返回值 Promise
await cmd.exec(cmd, opt)

cmd.classify

  • 参数

| param | type | description | |:---:|:---:|:---:| | argv | process.argv | node 命令行 process.argv |

  • 返回值 Object

        Object {
            all: argv,  // 所有参数的key value形式
            valuableParam,  // 有效参数
            cmdParam,  // 子命令
            objParam,  // 带等于号的参数
            commonParam,
            nameParam
        }
    ```
    
cmd.classify(process.argv)

Json

const {json} = require('pomelo-toolbox');

json.upJson

  • 参数

| param | type | description | |:---:|:---:|:---:| | cb | Function | 注入json文件内容的钩子,需要在函数中增加返回值。| | path | String |json文件的路径|

  • 返回值 Promise

        json.upJson((jsonData) => {
            jsonData.name = 'test';
            return jsonData;
        }, './test.json')

json.readJson

  • 参数

| param | type | description | |:---:|:---:|:---:| | path | Function | json文件的路径 | | key | String |需要读取的key|

  • 返回值 String
    json.readJson('./package.json')
    json.readJson('./package.json', 'version')

json.appendJson(path, dataObj)

  • 参数 | param | type | description | |:---:|:---:|:---:| | path | String| json文件的路径 | | dataObj | Object |需要为文件追加的数据|

  • 返回值 Boolean

    json.appendJson('./package.json', {
        test: 'test str'
    })

json.writeJson

说明同appendJson相同, 但writeJson为全量覆盖

Print

    const {print} = require('pomelo-toolbox')

print.Plog

  • 参数

| param | type | description | |:---:|:---:|:---:| | opt|Object| Plog的配置项 |

  • 返回值 Plog实例
    const Plog = require('pomelo-toolbox').Plog;
    new Plog({
        prefix: "pomelo-toolbox",
        des: true
    })

print.LogLoading

  • 参数

| param | type | description | |:---:|:---:|:---:| | opt|Object|LogLoading的配置项 |

  • 返回值 LogLoading实例
    const {LogLoading} = require('pomelo-toolbox').LogLoading;
    new LogLoading({
        txt: "we are trying, please wait...",
        prefixText: "",
        color: "cyan"
    })

print.LogPromise

  • 参数 | param | type | description | |:---:|:---:|:---:| |pro|Promise|| |opt|Object|LogLoading的配置项 |

  • 返回值 LogLoading实例

    const LogPromise = require('pomelo-toolbox').LogPromise;
    new LogPromise(pro, 'initing ...');
    new LogPromise(pro, opt);

SSH

    const {ssh} =  require('pomelo-toolbox');

ssh.ssh

  • 参数

| param | type | description | |:---:|:---:|:---:| |opt|Object|LogLoading的配置项 |

  • 返回值 Promise
    ssh.ssh({
        host: '192.168.1.111',
        port: '8888',
        username: 'root',
        password: '123'
    })

Step

    const {step} = require('pomelo-toolbox');

step.next

  • 参数

| param | type | description | |:---:|:---:|:---:| |cb|Function|异步回调|

  • 返回值 Promise
    step.next((resolve) => {
        if (..) {
            resolve(true)
        }
    })

step.sleep

  • 参数 | param | type | description | |:---:|:---:|:---:| |time|Number|延时时间| |cb|Function|延时结束时间|

  • 返回值 Promise

    await step.sleep(3000)