UNPKG

@leyyo/cache

Version:
27 lines (26 loc) 681 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * * class MyPromise extends Promise { * myMethod() { * return this.then(str => str.toUpperCase()); * } * } * * // Usage example 1 * MyPromise.resolve("it works") * .myMethod() * .then(result => console.log(result)) * .catch(error => console.error(error)); * * // Usage example 2 * await new MyPromise((resolve, reject) => { * if (Math.random() < 0.5) { * resolve("it works"); * } else { * reject(new Error("promise rejected; it does this half the time just to show that part working")); * } * }) * .myMethod(); * */