mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
removed old promises module
This commit is contained in:
parent
287778dd1b
commit
c19fc7770b
1 changed files with 0 additions and 33 deletions
|
@ -3,39 +3,6 @@ define(function (require) {
|
|||
|
||||
var module = require('modules').get('kibana/services');
|
||||
|
||||
module.service('promises', function ($q) {
|
||||
function playNice(fn, fns) {
|
||||
if (fns && _.isArray(fns) && _.isObject(fn)) {
|
||||
fns.forEach(function (method) {
|
||||
fn[method] = playNice(fn[method]);
|
||||
});
|
||||
return fn;
|
||||
}
|
||||
|
||||
return function playNiceWrapper() {
|
||||
// if the last arg is a callback then don't do anything
|
||||
if (typeof arguments[arguments.length - 1] === 'function') {
|
||||
return fn.apply(this, arguments);
|
||||
}
|
||||
|
||||
// otherwise create a callback and pass it in
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var defer = $q.defer();
|
||||
args.push(function (err, result) {
|
||||
if (err) return defer.reject(err);
|
||||
defer.resolve(result);
|
||||
});
|
||||
fn.apply(this, args);
|
||||
return defer.promise;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
playNice: playNice
|
||||
};
|
||||
});
|
||||
|
||||
// Provides a tiny subset of the excelent API from
|
||||
// bluebird, reimplemented using the $q service
|
||||
module.service('Promise', function ($q, $timeout) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue