Skip to content

joenix/promise-super

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Promise Super

Syntactic Sugar Imitation -- Self Entertainment

const promiseSuper = require('promise-super')
const promise = new promiseSuper(

	( resolve, reject ) => {

		if ( false )
		{
			reject('error')
		}
		else
		{
			resolve('success')
		}
	}

)
promise
	.then(
		( data ) => {
			console.log( data ); // success
			return `message ${data}` // will pass on next then
		}
	)
	.catch(
		( error ) => {
			console.log( error ) // error
		}
	)
	.finally(
		( data ) => {
			console.log( data ) // data is latest then return
		}
	)
promise.next(
	( data ) => {
		console.log( data ) // next run
	}
)
promise.then(
	( data, next ) => {
		next('next run')
	}
)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published