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

jwait

v1.0.1

Published

a jquery plugin ,which provide a easy way to delay your work

Downloads

13

Readme

jWait

a jquery plugin ,which provide a easy way to delay your work 为了少写几个setTimeout,哈哈

示例代码

原来

    setTimeout(function (){
        $('#b_1').addClass('active');
    },1000);

现在

    $('#b_1').jWait(1000).addClass('active');

原来 yet

    setTimeout(function (){
        $('#b_1').addClass('active');
        
        setTimeout(function (){
            $('#b_2').css({color:red});
        },1000);
    },1000);

==> 现在 now

    $('#b_1').jWait(1000).addClass('active')
             .jWait(1000)
             .jWait('#b_2').css({color:red});

原来 yet

    function doSth(){
        //...
    }

    setTimeout(function (){
        $('#b_1').addClass('active');
        doSth();
        setTimeout(function (){
            doSth();
            $('#b_2').css({color:red});
        },1000);
    },1000);

==> 现在 now

    function doSth(){
        //...
    }   
    
    $('#b_1').jWait(1000).addClass('active').jWait(doSth)
             .jWait(1000).jWait(doSth)
             .jWait('#b_2').css({color:red});

参数

/**
 *
 * @param waitObj  绑定对象可以是 (数字,字符串,对象,方法)
 * 1.数字 表示延迟的时间(单位:毫秒)
 * 2.字符串 查询字符串querySelector,表示切换代理的对象为查询字符串代表的jquery对象
 * 3.对象 代理的对象,表示切换代理的对象
 * 4.方法 延迟后执行的函数,如果没有延迟,则直接执行
 *
 * @param callback 回调方法,只有当waitObj是数字类型时有效
 * @returns {jWaitProxy} 返回一个执行代理对象,一个神奇的对象
 */
$.fn.jWait = function (waitObj, callback) {
//....
}