promisorydeprecated

Write API's with support for callbacks and Promises. Slim wrapper for JS return statements.

Usage no npm install needed!

<script type="module">
  import promisory from 'https://cdn.skypack.dev/promisory';
</script>

README

Promisory

CircleCI npm npm

Write API's with support for callbacks and Promises. Slim wrapper for JS return statements.

installation

  npm i promisory -S

Test

  npm test

Usage

More examples can be found in the test

import promisory from 'promisory';
  const getName = (firstname = '', callback) => {
    if (firstname) {
      return promisory.resolve(firstname, callback)
    }
    return promisory.reject(null, callback);
  }

Promise
  getName('Josh')
    .then((result) => console.log('Result: ', result))
    .catch((error) => console.log('ERROR: ', error));
Callback
  getName('Josh', (error, result) => {
    if (error) {
      console.log('ERROR: ', error);
    } else {
      console.log('Result ', result)  
    }
  });