Processing

Monster.Util. Processing

This class allows to execute several functions in order.

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

The result of run() is a promise.

You can create an instance via the monster namespace Monster.Util.Processing().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.0/dist/modules/util/processing.js';
new Monster.Util.Processing()
</script>

Alternatively, you can also integrate this class individually.

<script type="module">
import {Processing} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.0/dist/modules/util/processing.js';
new Processing();
</script>

Constructor

# new Processing(timeout, callback)

Class to be able to execute function chains

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

Parameters:
Name Type Description
timeout timeout

Timeout

callback function

Callback

Since:
  • 1.21.0
Example
import {Processing} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.0/dist/modules/util/processing.js';

let obj = {
   a: {
       b: {
           c: {
               d: "world"
           }
       }
   }
}

console.log(new Pipe('path:a.b.c.d | toupper | prefix:Hello\\ ').run(obj));
// ↦ Hello WORLD

Methods

# add(callback, time)

Adds a function with the desired timeout If no timeout is specified, the timeout of the previous function is used.

Parameters:
Name Type Description
callback function
time integer | undefined
Throws:
  • value is not a function

    Type
    TypeError
  • value is not an integer

    Type
    TypeError

# run(data) → {Promise}

Executes the defined functions in order.

Parameters:
Name Type Description
data *
Returns:
Type
Promise