Processing

Class to be able to execute function chains

Import
the javascript logo
import { Processing } from "@schukai/monster/source/util/processing.mjs";
Source
the git logo
Package
the npm logo
Since
1.21.0

A Simple Example

import {Processing} from '@schukai/monster/source/util/processing.mjs';

let startTime = +new Date();

new Processing((url) => {
    return fetch(url)
}, (response) => {
    // do something with the response
    console.log(response.status, +new Date() - startTime)
}, 200, () => {
    // this function is called 200 seconds after fetch is received.
    console.log('finished', +new Date() - startTime)
    return 'done'
}).run('https://monsterjs.org/assets/world.json').then(r => {
    console.log(r)
    // ↦ "done"
})

Exported

Processing

Derived from

Base

Options

The Options listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the Base.

Option
Type
Default
Description
-/-

Properties

The Properties listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Properties from these parent classes. If you cannot find a specific Properties in this list, we recommend consulting the documentation of the Base.

Methods

The methods listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the Base.

Constructor

constructor(args)
Parameters
  • args {...(int|function)}: args
Create new Processing Functions and timeouts can be passed. If a timeout is passed, it applies to all further functions. In the example timeout1, function1, function2, function3, timeout2, function4 the timeout1 is valid for the functions 1, 2 and 3 and the timeout2 for the function4. So the execution time is timeout1+timeout1+timeout1+timeout2

Behavioral methods

add(callback,time)
Parameters
  • callback {function}: callback
  • time {int|undefined}: time
Throws
  • {TypeError} value is not a function
  • {TypeError} value is not an integer
Adds a function with the desired timeout If no timeout is specified, the timeout of the previous function is used.

Other methods

run(data)
Parameters
  • data {*}: data
Returns
  • {Promise}
Executes the defined functions in order.

Events

This component does not fire any public events. It may fire events that are inherited from its parent classes.

The current width of the area is too small to display the content correctly.