0.5.0 • Published 6 years ago
@promises/reset v0.5.0
@promises/reset
Reset is package from Promises library
Use
Module
$ npm install --save @promises/reset
import {
default as reset
} from '@promises/reset';
Browser
<script src="https://unpkg.com/@promises/reset/bundle.umd.min.js"></script>
let {
reset
} = P;
Examples
let promise: Promise<string> = Promise.resolve<string>('foo');
reset(promise, 'bar').then((result: string) => {
console.log(result); // => 'bar'
});
let promise: Promise<string> = Promise.reject<string>('foo');
reset(promise, 'bar').then((result: string) => {
console.log(result); // => 'bar'
});
Functional programming
Module
$ npm install --save @promises/reset
import {
__,
default as reset
} from '@promises/reset/fp';
Browser
<script src="https://unpkg.com/@promises/reset/fp/bundle.umd.min.js"></script>
let {
__,
reset
} = PF;
Examples
let promise: Promise<string> = Promise.resolve<string>('foo');
reset('bar')(promise).then((result: string) => {
console.log(result); // => 'bar'
});
let promise: Promise<string> = Promise.reject<string>('foo');
reset('bar', promise).then((result: string) => {
console.log(result); // => 'bar'
});
Wrapper
Module
$ npm install --save @promises/reset
import Promises from '@promises/core';
import '@promises/reset/add';
Or
import Promises from '@promises/reset/add';
Browser
<script src="https://unpkg.com/@promises/core/bundle.umd.min.js"></script>
<script src="https://unpkg.com/@promises/reset/add/bundle.umd.min.js"></script>
let {
Promises
} = P;
Examples
let promises: Promises<string> = Promises.resolve<string>('foo').reset('bar');
promises.then((result: string) => {
console.log(result); // => 'bar'
});,
let promises: Promises<string> = Promises.reject<string>('foo').reset('bar');
promises.then((result: string) => {
console.log(result); // => 'bar'
});
Compatibility
These modules are written in typescript and available in ES5 and ES6 standard, the requirements are a global Promise (native or polyfill).
License
Copyright © 2017 Yisrael Eliav, Licensed under the MIT license.