mollitia
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Mollitia


Mollitia Icon

JavaScript Resilience Library

Mollitia is a JavaScript Resilience library that works on Node and on browsers.

Its purpose is to help organize asynchronous operations under a highly customizable circuit that helps manage error use cases.

When everything is falling apart, it stops the classic flow and uses modules to manage failures.

📄 Documentation

Please check out the official documentation to get started using Mollitia, visit genesys.github.io/mollitia.

⚙️ Installation

npm install --save mollitia

🚀 Usage

// Imports the library
import * as Mollitia from 'mollitia';
// Creates a circuit
const myCircuit = new Mollitia.Circuit({
	// Initializes a circuit with a handler
	func: yourFunction
});
// This will execute yourFunction('dummy')
await myCircuit.execute('dummy');
// Imports the library
import * as Mollitia from 'mollitia';
// Creates a retry module
const myRetryModule = new Mollitia.Retry({
	attempts: 2,
	interval: 500
});
// Creates a circuit
const myCircuit = new Mollitia.Circuit({
	// Initializes a circuit with a handler
	func: yourFunction,
	options: {
		modules: [
			// Adds a retry module to the circuit
			myRetryModule
		]
	}
});
// This will execute yourFunction('dummy'), but if it fails, it will retry two times, once every 500ms
await myCircuit.execute('dummy');

Package Sidebar

Install

npm i mollitia

Weekly Downloads

2,731

Version

0.1.1

License

MIT

Unpacked Size

144 kB

Total Files

24

Last publish

Collaborators

  • cadgerfeast
  • tichon29