rwaldron / promise Goto Github PK
View Code? Open in Web Editor NEWAn elegant promise implementation for Javascript
License: MIT License
An elegant promise implementation for Javascript
License: MIT License
== Promise v0.1.0 == An implementation of promises and futures for Javascript. To use, just grab the `Promise.js` file from the build directory. It works as a script tag and as a Node module. === new Promise() === Creates a new promise object. A promise can be in one of three states: pending, fulfilled, or rejected. A promise that is either fulfilled or rejected is called "resolved". You can query the promise for it's resolved value (which might be the expected value or an error) by using its associated future. === promise.resolve(value) === Resolves the promise with the specified value. If the provided value is a rejection, then the promise is "rejected". Otherwise the promise is "fulfilled". If the promise has already been resolved, then this function will throw an error. === promise.reject(error) === Rejects the promise with the specified error. If the promise has already been resolved, then this function will throw an error. === promise.future === The future associated with the promise. The future can be used to query the resolved value of the promise. === future.then(onSuccess, onFail = null) === Registers callbacks that will execute when the future's value is available. If the future results in an error, then the `onFail` callback will be called. Otherwise the `onSuccess` callback will be called. All callbacks execute asynchronously. Returns a future for the transformation applied by the callback functions. === Promise.when(valueOrFuture) === Returns a future for the specified argument. If the argument is itself a future then it will be returned without modification. === Promise.reject(error) === Returns a future for the specified error. === Promise.whenAll(array) === Returns a future for an array which contains the eventual value for every future in the input array. If any future in the input array fails, then the returned future fails. === Promise.whenAny(array) === Returns a future for the first resolved future in the input array.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.