Skip to content

Instantly share code, notes, and snippets.

@cowlicks
Last active September 1, 2020 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cowlicks/b759cde8a79a7a480f086f75c71d91af to your computer and use it in GitHub Desktop.
Save cowlicks/b759cde8a79a7a480f086f75c71d91af to your computer and use it in GitHub Desktop.
A concise implementation of a 'Deferred' object factory in javascript
function Deferred() {
const o = {},
p = new Promise((resolve, reject) => Object.assign(o, {resolve, reject}));
return Object.assign(p, o);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment