1.1.13 • Published 8 months ago

async-monitor.js v1.1.13

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

async-monitor.js

Build and Deployment Code Scanning

NPM Version

Known Vulnerabilities Coverage Status

(pseudo code)
<script>
	const watches = new Group();
	watches.addWatch({
			parent: undefined,
			child: 'a',
			f: function_to_watch
		});
	...watches.addWatch();
	 console.log(watches.tree);
	watches.watchAll()
	   .then(()=>console.log('All went well!'))
	   .catch(()=>console.log('Oops, at least 1 promise was rejected!'));
</script>
<pre>
── preparation step
   ├─ fetch data from ETL store: s1, fetch data from ETL store: s2
   │  └─ build snowflake s1 and s2
   │     └─ publish snowflake s1 and s2 ───────────────────────────┐
   └─ fetch data from ETL store: s3                                │
      └─ build snowflake from s3                                   │
         └─ publish snowflake s3 ──────────────────────────────────┤
                                                                   └─ completed
</pre>

Examples

Features

A lightweight and efficient monitoring engine designed to seamlessly track and manage hierarchically organized asynchronous JavaScript functions. Perfect for developers looking to streamline and gain insights into complex async workflows, ensuring reliable performance and easy debugging.

new in v1.1

The watchAll function is now an async function. This enhancement allows you to nest groups as needed and utilize then, catch, and finally for improved functionality and better control over your asynchronous workflows.

Examples

Explore various examples showcasing random hierarchies of asynchronous functions, graphically represented for better understanding and visualization. These examples demonstrate the flexibility and robustness of the monitoring engine in handling complex async workflows, making it easier to debug and optimize your code.

For demonstration purposes, an asynchronous function sleep(seconds, fail) is used to simulate an async operation. This function helps illustrate how the monitoring engine handles asynchronous tasks.

  • seconds: The number of seconds to wait before resolving (default is a random number between 0 and 3).
  • fail: A boolean indicating whether the function should reject (default is false). If undefined, there is a 50% chance of rejection.
  • returns: A promise that resolves after the specified seconds or rejects based on the fail condition.

In example 'demo04', descriptions ending with double exclamation marks (!!) contain a sleep function that is likely to reject. This highlights the monitoring engine's ability to handle and report failed asynchronous operations effectively.

Tests

npm install

To run the tests run:

npm test

If you want to add any feature or change existing features, you must run the tests to make sure you didn't break anything else. Any pull request (PR) needs to have updated passing tests for feature changes (or new passing tests for new features or fixes) in src/<file>.test.ts to be accepted. See

People

Maintainers: Manu Vanneste.

1.1.12

8 months ago

1.1.13

8 months ago

1.1.11

9 months ago

1.1.9

9 months ago

1.1.8

9 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.10

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

10 months ago

1.0.4

10 months ago