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

calculagraph

v0.2.2

Published

multifunctional calculagraph, support Node.js, Browser and RequireJS

Downloads

4

Readme

Calculagraph

多功能计时器

Here is an English edition

##安装

npm install calculagraph

使用

准备

  • Node.js

    var Calculagraph = require('calculagraph');
  • Browser Global

    console.log(Calculagraph);
  • RequireJS

    define(['Calculagraph'], function(Calculagraph){
        console.log(Calculagraph);
    });

Step 1: 构建time对象


var time = new Calculagraph();
 

Step 2: 设置起始时间

如果没有设置, 则默认为0。 当起始时间为0的时候, 逆时计时会自动停止。


time.set(20); // 设置起始时间为20秒

Step 3: 绑定计时器

可以看下面的例子

API

increase 递增计时绑定

  • 参数:
    • callback 每一个时刻触发的回调函数
    • interval 总运行时间
    • tick 每一个时刻的时间间隔
    • finish 完成之后触发的回调函数

descrease 递减计时绑定

  • 参数:
    • callback 每一个时刻触发的回调函数
    • interval 总运行时间
    • tick 每一个时刻的时间间隔
    • finish 完成之后触发的回调函数

set 设置起始的时间, 需要在调用decrease或者increase时运行

  • 参数:
    • time : 设置的时间, 单位是秒

stop 停止计时, 同时清空计时状态。

parse 暂停计时, 保留计时状态

restore 恢复上一次暂停时的计时状态

restart 重启计时,如果之前设置了起始时间, 则从起始时间开始运行。

AMD 加载器支持

若检测到AMD加载器,暴露Calculagraph构造函数,且不再将Calculagraph暴露到全局下

Example

逆时计时

    
var time = new Calculagraph();
time.set(30);
time.decrease(function(time){
    console.log(time);
}, 30, 500, function(){
    console.log('finishde');
});

顺时计时


var time = new Calculagraph();
time.set(15);
time.increase(function(time){
    console.log(time);
}, 20, 1000, function(){
    console.log('finished');
});

当前用户