New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sequence-stepper

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sequence-stepper

A small lib for asynchronous control stack of functions

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

#sequence-stepper

A small lib for asynchronous control stack of functions. It can start executing on any step in queue to the end.

##Usage

###class Stepper Creating a stepper queue

import {Stepper} from 'stepper';

let stepper = new Stepper([
  (step, data) => step.next(++data),
  (step, data) => data > 2 ? step.next(data * 2) : step.reject('fail'),
  (step, data) => console.log(data)
]);

Start executing

stepper.next(data);

You can return to the backward step with same code (backward step dos't execute)

stepper.prev();

Execute step after said stepDescriptor

stepper.next(data, stepper[2]);

Executing on some step in queue:

let savedStepDescriptor;

let stepper = new Stepper([
  (step, data) => {...},
  (step, data) => {
    //some behavior
    ...
    savedStepDescriptor = step;
    step.next();
  },
  (step, data) => {...}
]);

stepper.next()//execute queue to the end

savedStepDescriptor.next()//execute queue from saved step to the end;

###function sequence Its help you to make a function thats launches a queue to the end. You can make with that simple functional conveyors.

import {sequence} from 'Stepper'

let queue = sequence([
  (step, data) => step.next(data * 2),
  (step, data) => step.next(data + 4),
  (step, data) => data * 3,
])

let result = queue(5);//result === 42

You can add asynchronous behavior into steps

let queue = sequence([
  (step, data) => setTimeout(() => step.next(data + 11), 100),
  (step, data) => console.log(data * 2),
])

queue(10);//output 42 in console after 100ms

Keywords

FAQs

Package last updated on 09 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc