{"size": 757, "ext": "js", "max_stars_repo_path": "src/base.js", "max_stars_repo_name": "ElliotChong/exposed-promise", "max_stars_repo_stars_event_min_datetime": "2016-12-11T09:49:29.000Z", "max_stars_repo_stars_event_max_datetime": "2016-12-11T09:49:29.000Z", "max_issues_repo_path": "src/base.js", "max_issues_repo_name": "ElliotChong/exposed-promise", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/base.js", "max_forks_repo_name": "ElliotChong/exposed-promise", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.6285714286, "max_line_length": 70, "alphanum_fraction": 0.7291941876}
let NormalPromise = Promise

// Bluebird is used if available, otherwise fallback to native Promise
try {
	let Bluebird = require('bluebird')
	NormalPromise = Bluebird
} catch (error) {}

module.exports = function ExposedPromise (promiseHandler) {
	let exposedResolve
	let exposedReject

	// Generate a Promise instance and hoist resolve / reject
	const promise = new NormalPromise((resolve, reject) => {
		exposedResolve = resolve
		exposedReject = reject

		if (promiseHandler != null) {
			promiseHandler.apply(this, arguments)
		}
	})

	// Wrap resolve
	promise.resolve = function () {
		return exposedResolve.apply(this, arguments)
	}

	// Wrap reject
	promise.reject = function () {
		return exposedReject.apply(this, arguments)
	}

	return promise
}
