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

uojo-kit

v0.3.0

Published

实用工具库

Downloads

4

Readme

uojo-kit

常用 node 模块集合

使用

安装

npm install uojo-kit

代码中引入

const uojoKit = require("uojo-kit")

方法

log

对 console.log 进行分装,实现:log 输出的颜色定制、log 显示的代码行号

方法 | 功能 :---|:--- clog | log 输出的颜色定制 eclog | 显示代码执行行号

示例:

uojoKit.clog('red','content')
uojoKit.red('content') // 支持颜色:'black','red','green','yellow','blue','magenta','cyan','white','gray'
uojoKit.elog('content')

BufferExec(options)

对单任务队列执行进行缓冲执行。简单的说,这个类可以收集需要执行的任务,按顺序执行。

options 参数:

字段 | 默认值 | 作用 :---|:-------|:--- nextPoint | first |下一个执行的任务是取队列中新(last)旧(first) speedTaskEnter | 0 |任务进入队列的最小时间间隔 runBy | timeline |队列执行方式。timeline:时间轴,即当前任务执行完后取下一个任务后,在下一个任务执行前将当前队列中所有任务清空。queue:按队列顺序执行

方法: 名称 | 作用 :---|:----- trigger | 将任务推入执行队列,并触发该任务执行 receipt | 回执当前任务执行完毕

示例:

const bufferQueue = new uojoKit.BufferExec({
    runBy:'queue',
    speedTaskEnter:0
})

for(let i=0;i<5;i++){
    bufferQueue.trigger((next)=>{
        setTimeout(()=>{
            console.log(i)
            next(); //执行下一个任务
        })
        
    })
}

DelayExec(times)

对需要密集执行的任务,进行一定的过滤。即起到防火墙的效果

参数

参数 | 默认值 | 作用 :---|:---|:--- times | 0 | 任务最小间隔时间

方法

名称 | 作用 :---|:--- hit(recordName) | 需要执行的任务名,当recordName不传时,默认为 匿名记录

示例:

const fireWall = new uojoKit.DelayExec()
let count = 10;
let tid=setInterval(()=>{
    if(count<1){
        clearInterval(tid);
        return;
    }
    count--;
    if( fireWall.hit('fire') ){
        console.log('中弹')
    
    }else{
        console.log('阻挡')
    
    }
},30)

changeLog

0.3.0

  • LOG_LEVEL 替换为 LOG_ENV,且值为 debug 时才会执行 elog

0.2.0

  • elog 显示事件触发的完整路径

0.1.3

  • 修复 elog 显示行号的bug

0.1.2

  • 修复显示 Error 对象
  • 方法 clog 新增快捷调用方式:clog.red('...') 等于 clog('red','...')

0.1.1

  • 文档补充

0.1.0

  • 初始化。提供方法:log 模块、BufferExec 类、DelayExec 类