Skip to content

Instantly share code, notes, and snippets.

@joecliff
joecliff / possibleReturnValuesOfPromiseFuntion.js
Last active Aug 29, 2015
使用promise(q.js)时函数可能的返回值
View possibleReturnValuesOfPromiseFuntion.js
var Q = require('q');
function createPromise(data) {
var deffered = Q.defer();
setImmediate(deffered.resolve.bind(deffered, data));
return deffered.promise;
};
/**
* 第一步返回必须是promise,否则没有then...