1.0.2 • Published 8 years ago

treat-as-promise v1.0.2

Weekly downloads
1
License
ISC
Repository
-
Last release
8 years ago

Allows treating any variable as a promise. Useful if you want to conform to an asynchronous spec. If argument to treatAsPromise is already a promise, treatAsPromise will simply return the promise, so you can treat asynchronous / synchronous returned values in the same way

var treatAsPromise = require('treat-as-promise');

function getData() {
  // One day this will be returned from a server asynchronously!
  var data = { stuff: 'things' };
  return treatAsPromise(data);
}

getData()
.then(function(data) {
  console.log(data); // { stuff: 'things' }
});
1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago