gitmyhub

promise

JavaScript ★ 0 updated 9y ago ⑂ fork

ES6 Promise polyfill with Fiber support

Plain-English Explanation: promise

This is a JavaScript library that adds Promise support to older environments that don't have it built in. A Promise is a way to handle tasks that take time to complete—like fetching data from a server—without freezing up your entire application. If you're writing code in an environment that doesn't natively support Promises (which are part of modern JavaScript), this library fills that gap.

What makes this library special is its "Fiber support" feature. Fibers are a way to pause and resume code execution in a controlled manner. The library adds two custom methods—Promise.async and Promise.await—that let you write asynchronous code in a way that looks and feels synchronous, making it easier to read and reason about. Instead of chaining .then() callbacks or dealing with nested promises, you can write code that reads more like straightforward, top-to-bottom logic.

This is particularly useful for teams using Meteor, a JavaScript framework that makes building real-time web apps easier. The README mentions that if you're in a Meteor project, you can simply run meteor add promise to install it, and everything will be set up automatically. For other projects that want to use Fibers alongside this library, you just need to tell the Promise library which Fiber implementation you're using, and they'll work together smoothly.

The library essentially gives developers a choice: you can use standard Promise syntax if you prefer, or you can use the Fiber-based async and await methods if you want code that's easier to follow. It's a backward-compatible solution for environments that haven't caught up to modern JavaScript standards yet, while also offering a helpful alternative approach for teams that value readability and simpler flow control.