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

@panhezeng/countdown

v2.0.2

Published

countdown

Downloads

10

Readme

countdown

示例

点击预览

示例代码目录 /example

说明

构造函数参数 /**

  • @param nowTime 当前时间戳,毫秒,默认 new Date().getTime()
  • @param endTime 结束时间戳,毫秒, 必填
  • @param onUpdate 倒计时更新回调函数,必填,回调传值,倒计时对象{days,hours,minutes,seconds}
  • @param onComplete 倒计时结束回调函数
  • @param autoStart 自动开始倒计时,默认 true
  • @param update 初始化后立即执行一次更新回调函数,默认 false
  • @param padStart 更新回调函数返回对象的时间是否补零,默认 true
  • @param delay 触发更新回调函数的间隔时间,默认 1000 毫秒 */ 实例方法 init 和构造函数的参数一样,除了 autoStart,此方法可以用于 start 后,不销毁计时器的情况下,改变倒计时依赖的参数 start 开始倒计时,autoStart 为 false 时,手动开始倒计时可以调用此方法 update 更新倒计时方法,会执行 onUpdate 回调 getObject 参数 time,时间毫秒,必填,获得该时间的倒计时对象,{days,hours,minutes,seconds} clear 手动清除倒计时

补零功能使用了 String.prototype.padStart(),如需兼容老浏览器,自己添加 polyfill 修改了 output 方式,通过 require 或 window 方式使用,不需要加.default

用法

npm i @panhezeng/countdown -S

import Countdown from "@panhezeng/countdown";

const cdInstance = new Countdown({
  endTime: new Date().getTime() + 1081000,
  onUpdate: data => {
    console.log(`${data.hours}:${data.minutes}:${data.seconds}`);
  },
  onComplete: () => {
    console.log("cd complete");
  }
});

编译

# install dependencies
npm install

# 运行插件使用示例
npm run dev:example

# 编译插件
npm run build

# 发版
npm set registry https://registry.npmjs.org/ && npm set @panhezeng:registry https://registry.npmjs.org/ && npm version patch && npm publish --access public && npm set registry https://registry.npm.taobao.org/ && npm set @panhezeng:registry https://registry.npm.taobao.org/