modules

ac-bundle-module-utils-promise

utils/promise.js

A module for ac-bundle-app, published by ac-bundle-module.

Available Methods: wrap

wrap

function(value, p) {
  if (typeof value === "object") {
    p = value;
    value = "data";
  }
  return new Promise(function(resolve, reject) {
    p.then(function(d) {
      var data = {error: undefined};
      data[value] = d;
      resolve(data);
    }).catch(function(e) {
      var data = {error: e};
      data[value] = undefined;
      resolve(data);
    });
  });
}

Happy Coding!

Leave a Reply

Your email address will not be published. Required fields are marked *