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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cyy-tool

v1.0.11

Published

cyy-tool

Readme

cyy-tool

平时常用的一些函数和方法

使用示例


// DOM 元素全部加载完成
domReady(() => {
    // 加载之后要处理的逻辑
});

// 确保页面中 js/css 完全加载
const file = 'xxx.js';
loadFile(file, () => {
    // 加载之后要处理的逻辑
});

// url 上面获取参数对应的值
// 当前 url: https://www.baidu.com/?openId=1234abcd
const openId = getQueryString('openId');
console.log(openId);    // 1234abcd

// 返回一个在特点范围内的随机数字
// 需求:随机返回 4-14 范围内的数字
getRandomNum(4, 14);

// 鼠标滚轮事件
const oDiv = document.getElementById('div1');
addMouseWheel(oDiv, (bDown) => {
     if (bDown) {
         // 鼠标滚轮往上滚的时候触发回调
     } else {
         // 鼠标滚轮往下滚的时候触发回调
     }
});

// 判断对象是否为空,true -> json为空
const json = {};
isJsonEmpty(json);  // true

// 获取文件类型
const file = 'xxx.js';
getFileType(file);  // js

// 字符串间隔(字符串四位间隔)
stringSpacing('bankcard': '6225888888888888');  // 6225 8888 8888 8888
stringSpacing('phone': '15912341234');  // 159 1234 1234

// 将小于10的数字前面加上'0'
formatSingleNum(5); //  05

// 时间格式转换
formatDate(new Date().getTime());   // 2017.12.26 10:09:27

// 字符串截取(多余的显示省略号)
stringCut('我我我我我我我我我我我我我我我我我我');    // 我我我我我我我我我我...

// 数值添加千分位处理
formatThousands(1234567890456); // 1,234,567,890,456.00

// json 转成 url
const json = {
    name: 'abc',
    age: 18,
    school: '卧槽'
};
jsonTourl(json);    // name=abc&age=18&school=%E5%8D%A7%E6%A7%BD&t=0.7911412332962664

// 倒计时
// html 元素
// <div id="div1" class="class-div1"></div>
// <div class="class-div1"></div>
// <br>
// <div id="div2"></div>

const oShowTime1 = document.getElementById('div1');
const countdownTimeSec1 = 10;

// 调用方式一:从回调函数里面获取时间,自行决定显示方式
new setCountdown({
    serverTimestamp: new Date().getTime(),
    startTimestamp: (new Date().getTime() / 1000 + countdownTimeSec1) * 1000,
    showtime: function (time) {
        oShowTime1.innerHTML = time.day + '天' + time.hour + '小时' + time.min + '分' + time.sec + '秒';
    },
    timeup: function () {
        console.log('时间到1');
    }
});

// 输出:
// 00天00小时00分09秒

// 调用方式二:设置好显示的 html 元素和自定义显示的格式
new setCountdown({
    showTimeElement: '.class-div1',
    serverTimestamp: new Date().getTime(),
    startTimestamp: (new Date().getTime() / 1000 + countdownTimeSec1) * 1000,
    showTimeSymbol: {
        day: '天',
        hour: '小时',
        min: '分',
        sec: '秒'
    },
    timeup: function () {
        console.log('时间到2');
    }
});

// 输出:
// 00天00时00分06秒
// 00天00时00分06秒