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

@domain.js/parallel

v0.2.1

Published

domain.js parallel 通用模块

Downloads

13

Readme

@domain.js/parallel

Build status codecov

Installation

cnf

专属配置名称 parallel | 名称 | 类型 | 必填 | 默认值 | 描述 | 样例 | | ---- | ---- | ---- | ------ | ---- | ---- | | key | string | | | 记录并发锁的 redis 记录key | parallels | | defaultErrorFn | funtion | | | 处理并发锁申请错误函数 | Error |

deps

| 模块名 | 别名 | 用到的方法 | 描述 | | ------ | ---- | ---------- | ---- | | logger | | info | 输出观点时刻的信息,便于分析日志 | | graceful | | exit | 注册进程退出的执行函数,便于在退出时清理残留锁 | | redis | | hsetnx, hdel, hexists | 并发锁利用 redis hash 类型数据实现 | | utils | U | sleep | 实现在申请锁的等待功能 | | async | | whilst | 实现在申请锁,需要等待的时候循环等待 |

Usage

| 功能 | 描述 | 样例 | | ---- | ---- | ---- | | parallel | 封装一个函数,使其拥有并发控制的能力,不改变其原有行为 | parallel(fn, { path: 'test' }) |

parallel 函数参数

| 顺序 | 参数名 | 类型 | 必填 | 默认值 | 描述 | 样例 | | ---- | ------ | ---- | ---- | ------ | ---- | ---- | | 1 | fn | function | | | 要加工处理的函数 | const test = () => { } | | 2 | opt | object | | | 加工函数的参数控制 | { path: 'test' } | | 2 | opt.path | string | | | 并发控制锁名称 | test | | 2 | opt.keyFn | function | | | 计算并发锁名称的函数,第一个参数为 path, 之后为原函数的调用参数 | (path, name) => ${path}:${name} | | 2 | opt.minMS | integer | | 0 | 函数执行最小占用毫秒数,并发锁至少为保持这么长时间,单位毫秒 | 1000 | | 2 | opt.errorFn | function | | defaultErrorFn | 函数请求并发锁错误时调用的错误处理函数,不设置则会调用 defaultErrorFn | Error | | 2 | opt.needWaitMS | integer | | 0 | 函数是否对应需要执行,没有申请到就等待,needWaitMS 是循环判断的时间间隔,单位毫秒 | Error | | 2 | opt.neverReturn | Boolean | | false | 函数是否永不返回,相当于进程启动,只需要执行一次,后续一直不删除并发锁 | Error |