Skip to content

senaev/promise-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

$ npm install promise-function

Examples

You can do:

var promiseFunc = require('promise-function');

promiseFunc(function(param) {
        return 'justReturn ok: ' + param;
    }, 'paramObject')
    .then(function(val) {
        console.log(val);
    })
    .catch(function(error) {
        console.error(error);
    });

promiseFunc(function(param) {
        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                reject('returnPromiseReject ok: ' + param);
            }, 1000);
        });
    }, 'paramObject')
    .then(function(val) {
        console.log(val);
    })
    .catch(function(error) {
        console.error(error);
    });
    


promiseFunc(function(param) {
        var self = this;
        setTimeout(function() {
            self.resolve('callPromiseResolve ok: ' + param);
        }, 2000);
    }, 'paramObject')
    .then(function(val) {
        console.log(val);
    })
    .catch(function(error) {
        console.error(error);
    });

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published