{"size": 890, "ext": "js", "max_stars_repo_path": "node_modules/promise-toolbox/promisifyAll.js", "max_stars_repo_name": "frazzlick/Social_Club_Tracker", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/promise-toolbox/promisifyAll.js", "max_issues_repo_name": "frazzlick/Social_Club_Tracker", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/promise-toolbox/promisifyAll.js", "max_forks_repo_name": "frazzlick/Social_Club_Tracker", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.7096774194, "max_line_length": 78, "alphanum_fraction": 0.6269662921}
"use strict";

var promisify = require("./promisify");

var _require = require("./_utils"),
    forIn = _require.forIn;

var DEFAULT_MAPPER = function DEFAULT_MAPPER(_, name) {
  return !(name.endsWith("Sync") || name.endsWith("Async")) && name;
};

var promisifyAll = function promisifyAll(obj, _temp) {
  var _ref = _temp === void 0 ? {} : _temp,
      _ref$mapper = _ref.mapper,
      mapper = _ref$mapper === void 0 ? DEFAULT_MAPPER : _ref$mapper,
      _ref$target = _ref.target,
      target = _ref$target === void 0 ? {} : _ref$target,
      _ref$context = _ref.context,
      context = _ref$context === void 0 ? obj : _ref$context;

  forIn(obj, function (value, name) {
    var newName;

    if (typeof value === "function" && (newName = mapper(value, name, obj))) {
      target[newName] = promisify(value, context);
    }
  });
  return target;
};

module.exports = promisifyAll;