|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
417 bytes
|
| Line | |
|---|
| 1 | import utils from '../utils.js';
|
|---|
| 2 |
|
|---|
| 3 | const callbackify = (fn, reducer) => {
|
|---|
| 4 | return utils.isAsyncFn(fn)
|
|---|
| 5 | ? function (...args) {
|
|---|
| 6 | const cb = args.pop();
|
|---|
| 7 | fn.apply(this, args).then((value) => {
|
|---|
| 8 | try {
|
|---|
| 9 | reducer ? cb(null, ...reducer(value)) : cb(null, value);
|
|---|
| 10 | } catch (err) {
|
|---|
| 11 | cb(err);
|
|---|
| 12 | }
|
|---|
| 13 | }, cb);
|
|---|
| 14 | }
|
|---|
| 15 | : fn;
|
|---|
| 16 | };
|
|---|
| 17 |
|
|---|
| 18 | export default callbackify;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.