0.0.7 • Published 2 years ago

jrepromise v0.0.7

Weekly downloads
-
License
Apache License 2....
Repository
github
Last release
2 years ago

Repromise

This small class provides only three methods to easily handle JavaScript promises as jQueryDeferred or another promises libraries. Only is needed to class resolve() or reject() methods to handle promise status.

If you need a polyfill for promise, you can use Promise Polyfill.

Example of use

import { Repromise } from "jrepromise";

function exampleWithResolvedPromise() {
	const repromise = new Repromise();

	// do some stuff

	repromise.resolve("Value to resolve");
	return repromise.getPromise();
}

function exampleWithRejectedPromise() {
	const repromise = new Repromise();

	// do some stuff

	repromise.reject("Reason to reject");
	return repromise.getPromise();
}

async function repromiseTest() {
	console.log("Resolved to: " + await exampleWithResolvedPromise());

	try {
		await exampleWithRejectedPromise();
	} catch (error) {
		console.error("Rejected with reason: " + error);
	}
};

repromiseTest();

Methods of Repromise

  • resolve: Resolves the promise. Optionally can receive a value.
  • reject: Rejects the promise. A string with reject reason must be indicated.
  • getPromise: Gets the standar JavaScript promise.

Requests and issues

If you find an issue o make a request for a feature, Feel free to add it to library GitHub repository.

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago