var _ = require('lodash');
var NodeAxosoft = require('./');

function promisify(obj) {
  _.forEach(obj, function(fn, key) {
    if (_.isFunction(fn)) {
      obj[key] = function() {
        var args = Array.prototype.slice.call(arguments);

        return new Promise(function(resolve, reject) {
          args.push(function(error, result) {
            if (error) {
              reject(error);
            } else {
              resolve(result);
            }
          });

          fn.apply(null, args);
        });
      }
    }
  });
}

module.exports = function NodeAxosoftPromise() {
  var nodeAxosoft = NodeAxosoft.apply(null, arguments);

  _.forEach(nodeAxosoft, function(prop) {
    if (_.isObject(prop)) {
      promisify(prop);
    }
  });

  return nodeAxosoft;
};

@@ -637,24 +637,77 @@
  arguments);
+%0A  var nodeAxosoftPromise = _.cloneDeep(nodeAxosoft);
 %0A%0A  _.forEac
@@ -719,16 +719,23 @@
 eAxosoft
+Promise
 , functi
@@ -829,13 +829,20 @@
 eAxosoft
+Promise
 ;%0A%7D;%0A

fix issues caused by promise.js overwritting nodeAxosoft functions