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 🙏

© 2026 – Pkg Stats / Ryan Hefner

patrol-helper

v1.0.4

Published

A javaScript library designed to help developers manage camera preset polling

Readme

Patrol-Helper

Introduce

Patrol-Helper is a JavaScript library designed to help developers manage camera preset polling. It allows you to easily control camera presets, cycle through them, and execute custom actions at various stages of the polling process.

Installation

npm

Installing with npm is recommended and it works seamlessly with webpack.

npm install patrol-helper --save

CDN
Get the latest version from unpkg.com/patrol-helper , and import JavaScript file in your page.

<script src="https://unpkg.com/patrol-helper@latest/dist/patrol-helper.min.js"></script>

Usage

1.The usage of the preset poller.

Create a preset poller responsible for polling presets: start, pause, resume, and stop

import { createPresetPoller } from "patrol-helper";
// Parameter explanation: screendId: Screen number, starts from 1; cameraId: Camera gun ID; presetList: List of presets
const presetPoller = createPresetPoller(screendId, cameraId, presetList);
// Progress callback
presetPoller.onRun((i) => {
  console.log("multi-cloud preset: onRun", i);
  // add your code...
});
// Countdown callback
presetPoller.onCountdown((i) => {
  console.log("multi-cloud preset: onCountdown", i);
  // add your code...
});
// Resume callback
presetPoller.onResume(() => {
  console.log("multi-cloud preset: resume");
  // add your code...
});
// Pause callback
presetPoller.onPause(() => {
  console.log("multi-cloud preset: onPause");
  // add your code...
});
// End callback
presetPoller.onEnd((i) => {
  console.log("multi-cloud preset: onEnd", i);
  // add your code...
});
// Start the timer
presetPoller.start();

Explanation of Code:

  • createPresetPoller: Initializes a polling system for camera presets based on screen ID, camera ID, and a list of preset positions.
  • Callbacks:
    • onRun: Executes when polling begins.
    • onCountdown: Executes during the countdown before switching to the next preset.
    • onResume: Executes when the polling resumes after being paused.
    • onPause: Executes when the polling is paused.
    • onEnd: Executes when polling finishes.
  • presetPoller.start(): Starts the polling process.
    You can replace the // add your code... comments with any custom logic you need to implement at each stage.

2.The usage of the single-screen poller.

import { createScreenPoller } from "patrol-helper";

const screenPoller = createScreenPoller(screendId, list);

// Create callback
screenPoller.onCreate((i) => {
  console.log("single patrol: onCreate", i);
  // add your code...
});

// Resume polling
screenPoller.onResume((i) => {
  console.log("single patrol: onResume", i);
  // add your code...
});

// Pause polling
screenPoller.onPause((i) => {
  console.log("single patrol: onPause", i);
  // add your code...
});

// Countdown callback
screenPoller.onCountdown((i) => {
  console.log("single patrol: onCountdown", i);
  // add your code...
});

// Terminate or stop polling
screenPoller.onTeminate((i) => {
  console.log("single patrol: onTeminate", i);
  // add your code...
});

// Polling progress callback
screenPoller.onProgress((i) => {
  console.log("single patrol: onProgress", i);
  // add your code...
});

// Before moving to the next camera
screenPoller.onProgressBeforeNext(async (i) => {
  console.log("single patrol: onProgressBeforeNext", i);
  // add your code...
});

// Start the polling process
screenPoller.start();

Explanation of Code:

  • createScreenPoller: Initializes a polling system for a single screen, where screendId is the screen number and list is an array of camera guns.
  • Callbacks:
    • onCreate: Triggered when polling is created.
    • onResume: Triggered when polling is resumed.
    • onPause: Triggered when polling is paused.
    • onCountdown: Triggered during the countdown before switching to the next camera.
    • onTeminate: Triggered when polling is terminated or ended.
    • onProgress: Triggered during the polling progress.
    • onProgressBeforeNext: Triggered before moving to the next camera.
  • screenPoller.start(): Starts the polling process.

3.The usage of single-screen poller manager

Create a single-screen poller manager(for the convenience of batch controlling single-screen pollers) responsible for adding, deleting, and finding single-screen pollers

import { createSinglePollerManager } from "patrol-helper";
// Create a single-screen poller manager
const spm = createSinglePollerManager();
// Create a single-screen poller
const sp = createScreenPoller(screendId, list);
// Add the single-screen poller to the single-screen poller manager
spm.addPoller(sp);
// Check if a single-screen poller with screen ID 'screendId' exists
spm.has(screendId);
// Get the capacity of the single-screen poller manager
spm.size();
// Delete the single-screen poller with screen ID 'screendId'
spm.deletePoller(screendId);
// Start all single-screen pollers in the single-screen poller manager
spm.start();
// Find the single-screen poller by its screen ID 'screendId'
const sp = spm.findByPId(screendId);

Explanation of Code:

  • createSinglePollerManager: Creates a manager that handles multiple single-screen pollers.
  • addPoller(sp): Adds a single-screen poller to the manager.
  • has(screendId): Checks if a single-screen poller with the given screen ID exists in the manager.
  • size(): Returns the number of single-screen pollers in the manager.
  • deletePoller(screendId): Deletes the single-screen poller with the specified screen ID from the manager.
  • start(): Starts all single-screen pollers in the manager.
  • findByPId(screendId): Finds and retrieves the single-screen poller by its screen ID.

4.The usage of multi-screen poller

Create a multi-screen poller: responsible for pausing, resuming, deleting, and stopping the multi-screen patrol sequence

import { createMutiPollerManager } from "patrol-helper";

const mpm = createMutiPollerManager();

mpm.init(data, screenNum, interval);

mpm.onCountdown((i) => {
  console.log("multi patrol: onCountdown", i);
  // add your code...
});

mpm.onProgressBeforeNext(async (i) => {
  console.log("multi patrol: onProgressBeforeNext", i);
  // add your code...
});

mpm.onPause((i) => {
  console.log("multi patrol: onPause", i);
  // add your code...
});

mpm.onResume((i) => {
  console.log("multi patrol: onResume", i);
  // add your code...
});

mpm.onTerminate((i) => {
  console.log("multi patrol: onTerminate", i);
  // add your code...
});

mpm.onProgress((i) => {
  console.log("multi patrol: onProgress", i);
  // add your code...
});

mpm.start();

Explanation of Code:

  • createMutiPollerManager: Initializes the multi-screen patrol manager responsible for managing the patrol sequence.
  • Parameters:
    • data: An array of camera guns.
    • screenNum: The number of screens for the patrol.
    • interval: The time interval for the patrol.
  • Callbacks:
    • onCountdown: Triggered during the countdown before the patrol begins.
    • onProgressBeforeNext: Triggered before moving to the next patrol step.
    • onPause: Triggered when the patrol is paused.
    • onResume: Triggered when the patrol is resumed.
    • onTerminate: Triggered when the patrol is terminated.
    • onProgress: Triggered during the patrol progress.
  • mpm.start(): Starts the multi-screen patrol process.
    You can insert your own custom logic within the comments to handle specific actions during each event.

5.The usage of the multi-screen cloud patrol manager.

Create a multi-screen cloud patrol manager: responsible for pausing, resuming, fast-forwarding, and stopping multi-screen patrols

import { createMutiCloudPollerManager } from "patrol-helper";

const mcpm = createMutiCloudPollerManager();

mcpm.init(data, screenNum, interval);

mcpm.onProgressBeforeNext((i) => {
  console.log("multi cloud patrol: onProgressBeforeNext", i);
  // add your code...
});

mcpm.onPause((i) => {
  console.log("multi cloud onPause:", i);
  // add your code...
});

mcpm.onResume((i) => {
  console.log("multi cloud onResume:", i);
  // add your code...
});

mcpm.onTerminate((i) => {
  console.log("multi cloud onTerminate:", i);
  // add your code...
});

mcpm.onProgress(async (i) => {
  console.log("multi cloud onProgress:", i);
  return i.next(); // Call i.next() to move to the next step
});

mcpm.start();

Explanation of Code:

  • createMutiCloudPollerManager: Initializes the multi-screen cloud patrol manager responsible for managing the patrol process.
  • Parameters:
    • data: An array of camera guns.
    • screenNum: The number of screens in the patrol.
    • interval: The time interval between each patrol.
  • Callbacks:
    • onProgressBeforeNext: Triggered before moving to the next screen.
    • onPause: Triggered when the patrol is paused.
    • onResume: Triggered when the patrol is resumed.
    • onTerminate: Triggered when the patrol is terminated.
    • onProgress: Triggered during the patrol progress. The method i.next() is used to proceed to the next step in the process.
  • mcpm.start(): Starts the multi-screen patrol process.
    You can insert your own logic in place of the comments to handle the specific actions you want to perform at each event.