diff options
author | Alexander Early <alexander.early@gmail.com> | 2016-02-23 16:09:53 -0800 |
---|---|---|
committer | Alexander Early <alexander.early@gmail.com> | 2016-02-23 16:10:07 -0800 |
commit | 070ed49496d5cf0b3c31a8091608610961191238 (patch) | |
tree | e26f489e37ae3a227867b3d1dfe6c04afa361c23 /build-es/asyncify.js | |
parent | 3cf46d01b44c31203f4e59db280378a58d760d0d (diff) | |
download | async-modularization.tar.gz |
gitignore build directoriesmodularization
Diffstat (limited to 'build-es/asyncify.js')
-rw-r--r-- | build-es/asyncify.js | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/build-es/asyncify.js b/build-es/asyncify.js deleted file mode 100644 index 9239e99..0000000 --- a/build-es/asyncify.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -import isObject from 'lodash-es/isObject'; -import rest from 'lodash-es/rest'; - -export default function asyncify(func) { - return rest(function (args) { - var callback = args.pop(); - var result; - try { - result = func.apply(this, args); - } catch (e) { - return callback(e); - } - // if result is Promise object - if (isObject(result) && typeof result.then === 'function') { - result.then(function(value) { - callback(null, value); - })['catch'](function(err) { - callback(err.message ? err : new Error(err)); - }); - } else { - callback(null, result); - } - }); -} |