is-a-promise

0.1.0 • Public • Published

var Promise = require('./index');

var a = new Promise(function(resolve,reject) { setTimeout(function() { resolve(2); },3000) }); a.then(function(v) { console.log(v) return new Promise(function(resolve) { setTimeout(function(){ resolve(new Promise(function(resolve) { setTimeout(function() { resolve(123) },3000) })); },3000) }) }).then(function(x){ console.log(x) },function(x){ console.log(x); return 22 })

//-----------------------------

var promiseA = new Promise(function(resolve) { setTimeout(function() { resolve(111); },2000) });

var promiseB = new Promise(function(resolve,reject) { setTimeout(function() { resolve(222); },3000) }); Promise.all([promiseA,promiseB]).then(function(result) {//or Promise.race([]) console.log(result) return 22222; },function(value) { console.log(value); }).then(function(x) { console.log(x) });

//-----------------------------

Promise.resolve(1).then(function(x) { console.log(x) })

//-----------------------------

var promiseA = new Promise(function(resolve,reject) { setTimeout(function() { reject(111); },2000) });

promiseA.then(function(s){ console.log(s) console.log(q) },function() { console.log(1) }).catch(function(value){ console.log(value) }) a = new Promise(function(resolve,reject) { setTimeout(function() { reject(Promise.resolve(2)) },1000) }) a.then(void 0,function(x) { console.log(x) return 1 }) a.then(function(x) { return 2 },function(x){ console.log(x); return 3 }) .then(function(x){ console.log(x) })

Readme

Keywords

Package Sidebar

Install

npm i is-a-promise

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • theanarkh