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

mpatroler

v1.0.1-rc

Published

A simple patroler

Downloads

222

Readme

MPatroler

Introduce

要在您的 Node.js 项目中使用 mpatroler.js,只需使用 npm 安装

 npm install mpatroler

cnpm 安装

 cnpm install mpatroler

yarn 安装

 yarn add mpatroler

pnpm 安装

 pnpm install mpatroler

您也可以使用CDN 的方式引入资源

<!-- 引入 mpatroler -->
<script src="https://cdn.jsdelivr.net/npm/mpatroler@latest/dist/mpatroler.bundle.min.js"></script>
<!-- 或者 -->
<script src="https://unpkg.com/mpatroler@latest/dist/mpatroler.bundle.js" ></script>

Usage

1.预置位轮询器的使用
// 创建预置位轮询器 负责预置位轮巡 开始 暂停 恢复 停止
import { createPresetPoller } from "mpatroler";
// 参数说明: subId: 屏幕号,从1开始;  cameraId:摄像枪Id;  presetList:预置位列表
createPresetPoller(subId, cameraId, presetList)
  // 进度回调
  .onRun((i) => {
    console.log("muti cloud preset: onRun", i);
    // add your code...
  })
  // 倒计时回调
  .onCountdown((i) => {
    console.log("muti cloud preset: onCountdown", i);
    // add your code...
  })
  // 恢复回调
  .onResume(() => {
    console.log("muti cloud preset: resume");
    // add your code...
  })
  // 暂停回调
  .onPause(() => {
    console.log("muti cloud preset: onPause");
    // add your code...
  })
  // 结束回调
  .onEnd((i) => {
    console.log("muti cloud preset: onEnd", i);
    // add your code...
  })
  // 定时器开启
  .start();
2.单屏轮询器的使用
// 创建单屏轮询器: 负责单屏轮巡 开始 暂停 恢复 停止
import { createScreenPoller } from "mpatroler";
// 参数说明: subId 屏幕号 从1开始; list 摄像枪列表数组
createScreenPoller(subId, list)
  .onCreate((i) => {
    console.log("single patrol: onCreate", i);
    // add your code...
  })
  // 轮巡恢复
  .onResume((i) => {
    console.log("single patrol: onResume", i);
    // add your code...
  })
  // 轮巡暂停
  .onPause((i) => {
    console.log("single patrol: onPause", i);
    // add your code...
  })
  // 倒计时
  .onCountdown((i) => {
    console.log("single patrol: onCountdown", i);
    // add your code...
  })
  // 轮巡中止、结束
  .onTeminate((i) => {
    console.log("single patrol: onTeminate", i);
    // add your code...
  })
  // 轮巡进度
  .onProgress((i) => {
    console.log("single patrol: onProgress", i);
    // add your code...
  })
  // 进入下根枪之前
  .onProgressBeforeNext(async (i) => {
    console.log("single patrol: onProgressBeforeNext", i);
    // add your code...
  })
  .start();
3.单屏轮询器管理者 (为了方便批量控制单屏轮询器)的使用
// 创建单屏轮巡器管理者 负责添加 删除 查找单屏轮巡器
import { createSinglePollerManager } from "mpatroler";
// 创建单屏轮巡器管理者
const spm = createSinglePollerManager();
//创建单屏轮询器
const sp = createScreenPoller(subId, list);
// 将单屏轮询器加入单屏轮询器管理者
spm.addPoller(sp);
// 判断屏号为subId的单屏轮询器是否存在
spm.has(subId);
//单屏轮询器管理者的容量
spm.size();
//刪除屏号为subId的单屏轮询器
spm.deletePoller(subId);
// 单屏轮询器管理者 内的所有单屏轮询器开启
spm.start();
// 根据subId 查找对应的单屏轮询器
const sp = spm.findByPId(subId);
4.多屏轮询器的使用
// 创建多屏轮询器: 负责 暂停 恢复 删除 停止 多屏轮序
import { createMutiPollerManager } from "mpatroler";

createMutiPollerManager()
  // 参数说明: data 摄像枪数组;  screenNum 分屏数; interval 轮巡时间间隔
  .init(data, screenNum, interval)
  .onCountdown((i) => {
    console.log("muti patrol: onCountdown", i);
    // add your code...
  })
  .onProgressBeforeNext(async (i) => {
    console.log("muti patrol: onProgressBeforeNext", i);
    // add your code...
  })
  .onPause((i) => {
    console.log("muti patrol: onPause", i);
    // add your code...
  })
  .onResume((i) => {
    console.log("muti patrol: onResume", i);
    // add your code...
  })
  .onTerminate((i) => {
    console.log("muti patrol: onTerminate", i);
    // add your code...
  })
  .onProgress((i) => {
    console.log("muti patrol: onTerminate", i);
    // add your code...
  })
  .start();
5.多屏云台轮询器的使用
// 创建多屏云台轮询器: 负责 暂停 恢复 快进 停止 多屏轮巡
import { createMutiCloudPollerManager } from "mpatroler";

createMutiCloudPollerManager()
  // 参数说明: data 摄像枪数组;  screenNum 分屏数; interval 轮巡时间间隔
  .init(data, screenNum, interval)
  .onProgressBeforeNext(async (i) => {
    console.log("muti cloud patrol: onProgressBeforeNext", i);
    // add your code...
  })
  .onPause((i) => {
    console.log("muti cloud onPause:", i);
    // add your code...
  })
  .onResume((i) => {
    console.log("muti cloud onResume:", i);
    // add your code...
  })
  .onTerminate((i) => {
    console.log("muti cloud onTerminate:", i);
    // add your code...
  })
  .onProgress(async (i) => {
    console.log("muti cloud onProgress:", i);
    return i.next(); // 调用 i.next()才会往下走
    // add your code...
  })
  .start();