1.0.1 • Published 6 years ago

@walkerbe/promiser v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Promiser

A sample implementation of Promises/A+.

Usage

npm i @walkerbe/promiser

Example:

import Promise from '@walkerbe/promiser';

let p1 = function () {
  return new Promise((resolve, reject) => {
    setTimeout(function () {
      resolve('hello Promise');
    }, 1000);
  });
};


p1().then((res) => {
  console.log('res: ', res);
}, (error) => {
  console.log('error: ', error);
}).catch((error) => {
  console.log('error finally: ', error);
});
// res:  hello Promise


// with async await
async function asyncTest() {
  let res = await p1();
  console.log('async function result: ', res);
}

asyncTest();
// async function result:  hello Promise

Include Methods

Test

Use promises-aplus-tests to test.

npm run test

Todos

  • implement Promises/A+
  • use rollup to build
  • add methods: resolve, reject, all, race, finally

License

MIT License

1.0.1

6 years ago

1.0.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago