Socket
Socket
Sign inDemoInstall

jueue

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jueue

For proper coding and to run sequential asynchronous function.


Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

jueue

For proper coding and to run sequential asynchronous function.

Installation

$ npm install jueue

Usage

var jueue = require('jueue');

// To set jueue options.

jueue.set({
  running: true,
  pauseTime: 1000
});

// or

jueue.set("running", true);
jueue.set("pauseTime", 1000);

// No settings needed at the start. Because all settings have defaults.

// To use queue for functions.

jueue.get(
  function (e) {
    //...
    e.next();
  },
  function (e) {
    //...
    // If there is an error
    e.throw(error);
    // or complete jueue.
    e.done(); // this calls then function callback
  }
).then(function (result) {
  // Write function to manage done.
}).catch(function(err) {
  // Write function to catch error.
});

var jueue = require('jueue');
jueue.get(
  function (e) {
    //...
    e.next({ name: "test", model: "test", args: [1, 2] });
  },
  function (e) {
    //...
    e.next();
  },
  function test(e, one, two) {
    var modelValue = e.model;
    //...
  }
);

Methods

jueue.set([options]) or jueue.set(key, value)

Parameters:

  • [options]: Optional object containing any of the following properties:

    • running: Indicates the working status of all queues. Default value: true

    • pauseTime: Indicates the duration of next pause control. Default value: 1000

Or

  • key: String key names of the above properties (running or pauseTime).

  • value: Value of the above properties (running or pauseTime).

jueue.get(list) or jueue.get()

Parameters:

  • [list]: Required array of functions. For queue.

Or

  • [arguments]: list may write like arguments.
jueue.promise(list) or jueue.promise()

Used to get instance of promise for jueue.

Parameters:

  • [list]: Required array of functions. For queue.

Or

  • [arguments]: list may write like arguments.
jueue.catch(ecb)

Parameters:

  • ecb: Optional error function. Used to catch errors.
jueue.then(cb)

Parameters:

  • cb: Optional done function. Used to catch done.
e.next([options]) or e.next(step) or e.next(name)

Parameters:

  • [options]: Optional object containing any of the following properties:

    • step: The index of the function you want to go directly.

    • name: The name of the function you want to go directly.

    • model: The object model you want to send to the next function.

    • args: The arguments you want to send to the next function.

Or

  • step: The index of the function you want to go directly. options may write like step.

Or

  • name: The name of the function you want to go directly. options may write like name.
e.throw(err)

Parameters:

  • err: It must be instance of Error.
e.done(result)

Parameters:

  • result: Object that you want to send.

Examples

Basic Usage

This example shows the most basic way of usage.

License

This software is free to use under the JosephUz. See the LICENSE file for license text and copyright information.

Keywords

FAQs

Package last updated on 14 Aug 2020

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc