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

cuj

v1.0.16

Published

Common Use Js

Readme

CUJs

基于ES6编写的常用JS函数

CSS 类

  • hasClass(class)

检查当前的元素是否含有某个特定的类,如果有,则返回true。

  • addClass(class)

为每个匹配的元素添加指定的类名,一个或多个要删除的CSS类名,请用空格分开。

  • removeClass(class)

从所有匹配的元素中删除全部或者指定的类,一个或多个要删除的CSS类名,请用空格分开。

  • toggleClass(class)

如果存在(不存在)就删除(添加)一个类。

效果

  • show()

显示隐藏的匹配元素。

  • hide()

隐藏显示的元素。

String

  • getQueryString()
// abc.com?test=123
CUJs.String.getQueryString('test')  // 123
  • limitText()
let abc = 'abc12345678'
CUJs.String.getQueryString(abc,7)  // abc1234...

Array

  • unique(arr)
let arr = [1,3,4,5,8,5,3,9]
CUJs.Array.unique(arr)  // [1,3,4,5,8,9]

Date

  • format(fmt,date)
let _date = new Date();
CUJs.Date.format('yyyy-MM-dd hh:mm:ss',_date)  // 2018-05-30 10:05:54
CUJs.Date.format('yyyy-MM-dd',_date)  // 2018-05-30
CUJs.Date.format('M月d日 hh:mm:ss',_date);  // 5月30日 10:05:54
CUJs.Date.format('yyyy/MM/dd hh:mm',_date);  // 2018/05/30 10:05

Function

  • CountDown(el,options)
var app = document.getElementById('app');
var count = new CUJs.CountDown(app,{
    countDownSeconds: 7,       //倒计时间设置
    doubleDigit: true,          //'7'秒显示为'07'
    secondsOnly: false,         //是否只显示秒
    callback = () => {          //倒计时完回调函数
        return false;
    }
})