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

@agoyu/procaser

v0.2.1

Published

To combine processing into a single callback function which can be handled by a switch-case statement.

Readme

Procaser

To combine processing into a single callback function which can be handled by a switch-case statement.

Installation


npm i @agoyu/procaser

Usage


import {Procaser} from '@agoyu/procaser';

  new Procaser(null, (proc, step, props) => {
    switch (step) {
      case proc.BOOT:
        proc.next('MyStep');
        break;
      case 'start@MyStep':
        // write your process management
        // ...
      case proc.EXIT:
        break;
    }
  });

Example


processJob(willSuccess) {
  const myProps = {
    name: 'Potesuke',
    email: '[email protected]'
  };
  
  const caser = new Procaser(
    myProps,
    (proc, step, props) => {
      console.log('step:' + step);
      switch (step) {
        case proc.BOOT:
          proc.next('Process');
          break;

        case 'start@Process':
          this.showProgressPopup({
            title: 'Processing',
            caption: 'Please Wait',
          });
          this.requestProcess(proc, willSuccess);
          break;
        case 'end@Process':
          this.showProgressPopup(false);
          break;
        case 'success@Process':
          proc.next('Complete');
          break;
        case 'failed@Process':
          proc.next('Failed');
          break;

        case 'start@Complete':
          this.showConfirmPopup(
            {
              title: 'Process succeeded',
              caption: 'You made it!',
              yes: 'OK',
              no: false,
            },
            proc);
          break;
        case 'end@Complete':
          this.showConfirmPopup(false);
          break;
        case 'confirm@Complete':
          proc.exit();
          break;

        case 'start@Failed':
          this.showConfirmPopup(
            {
              title: 'Process failed',
              caption: 'Try again!',
              yes: 'OK',
              no: false,
            },
            proc);
          break;
        case 'end@Failed':
          this.showConfirmPopup(false);
          break;
        case 'confirm@Failed':
          proc.exit();
          break;
        
        case proc.EXIT:
          break;
      }
    }
  );
}

/**
 * Send the signal to the Procaser after 2 seconds
 * @param {Procaser} proc 
 * @param {boolean} willSuccess 
 */
 requestProcess(proc, willSuccess) {
  setTimeout(() => {
    if (willSuccess) {
      proc.signal('success');
    } else {
      proc.signal('error');
    }
  }, 2 * 1000);
}

Methods

constructor

constructor

Parameters

  • props (object | null) The object you can deal with in the Procaser instance. (optional, default {})
  • callback Function Function to be called back when the step or state is changed (optional, default (step:string,proc:Procaser,props:object)=>{})

next

Moving on to the next step, the callback passes through "end@currentStep" and "start@nextStep" case statements

Parameters

  • stepName (string | undefined) Next step name
  • props object Values to be assigned to the properties (optional, default {})
  • wait number Millisecond time before the callback on the next step starting. If negative, immediately. (optional, default -1)

Returns this

exit

Terminates the process, the callback passes through "end@currentStep" and proc.EXIT case statements

Returns this

signal

Apply state to the current step, the callback passes through "yourState@currentStep" case statement

Parameters

  • state string Any state name
  • props object Values to be assigned to the properties (optional, default {})
  • wait number Millisecond time before the callback passes through the "yourState@currentStep" case statement. If negative, immediately. (optional, default -1)

Returns this

confirm

Apply the 'confirm' state to the current step, the callback passes through "confirm@currentStep" case statement

Parameters

  • props object Values to be assigned to the properties (optional, default {})
  • wait number Millisecond time before the callback passes through the "confirm@currentStep" case statement. If negative, immediately. (optional, default -1)

Returns this

cancel

Apply the 'cancel' state to the current step, the callback passes through "cancel@currentStep" case statement

Parameters

  • props object Values to be assigned to the properties (optional, default {})
  • wait number Millisecond time before the callback passes through the "cancel@currentStep" case statement. If negative, immediately. (optional, default -1)

Returns this

error

Apply the 'error' state to the current step, the callback passes through "error@currentStep" case statement

Parameters

  • stepName string
  • props object Values to be assigned to the properties (optional, default {})
  • wait number Millisecond time before the callback passes through the "error@currentStep" case statement. If negative, immediately. (optional, default -1)

Returns this