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

cyp-socket

v1.0.6

Published

socket处理工具

Downloads

2

Readme

为了提升开发团队应对业务需求的响应速度,提高跨平台技术栈的应用占比;需要对H5、RN的技术卡点逐一攻破;本工具的出发点是为了满足项目内大量竞拍倒计时的快捷处理。

项目地址 devops 语雀地址

目的

通过简单方法调用可方便处理针对如 xx:xx:xx 格式的倒计时

使用方法

浏览器

安装:

yarn add '@souche-f2e/worker-timer'

使用:

import Timer from '@souche-f2e/worker-timer';

// 向任务队列内添加并开始为id的倒计时
Timer.start({
  id: '01',                             // 该计时的唯一标识
  time: state.time,                     // xx:xx:xx 格式的时间
  update: (d) => { state.time = d; },   // 更新时间回调:(time) => { }
  trigger: () => { onCheckTimeOut(); }, // 倒计时结束时触发回调
});

// 停止id的倒计时
Timer.stop('01'); 

// 清空任务队列内的所有倒计时
Timer.clear(); 

// 关闭webworker,执行后不可再start(),建议在页面入口文件统一卸载
Timer.terminate(); 

微信小程序Taro

由于小程序对worker的加载路径及方式有特定要求,这里现提供手动加载的方式供使用

  1. 在app.json 内添加 workers: 'worker' 配置;
  2. 在微信小程序项目根目录新建文件夹 worker ;
  3. 将本仓库内 wxmini/tick.worker.js 复制到 上一步新建的文件夹中;
  4. 将本仓库内 wxmini/timer.js 复制到 项目内后即可使用,api与上面一致。

兼容性

sdk 内对 syntaxbabel进行了转换,考虑只兼容ios10+,为保障体积与性能,故没有对MappadStart等方法进行转换。

ios10以及10以上

性能

全局单例worker,单例setInterval,能够保障倒计时的性能与准确性。

测试调用商户端PC的线上竞拍大厅车列表接口,100+辆车,1小时倒计时,前后台任务测试无误差。

资源大小

worker-timer/lib/index.js

+--------------------------------------------------------------+

| Size | 4.01 KiB |

|--------------------------------------------------------------|

| Gzipped | 2.03 KiB |

|--------------------------------------------------------------|

| Mime type | application/javascript |

+--------------------------------------------------------------+

实现原理

关键词:rollup、webworker、发布订阅模式

image.png