Do not depend on Bluebird.

This commit is contained in:
Julien Fontanet 2015-12-30 19:00:32 +01:00
parent b8e2cfc47f
commit 84fbe9ee06
2 changed files with 16 additions and 2 deletions

View File

@ -27,7 +27,6 @@
],
"dependencies": {
"babel-runtime": "^6.3.19",
"bluebird": "^3.1.1",
"event-to-promise": "^0.6.0",
"exec-promise": "^0.5.1",
"fs-promise": "^0.3.1",

View File

@ -3,7 +3,6 @@
import eventToPromise from 'event-to-promise'
import { createClient } from 'ldapjs'
import { escape } from 'ldapjs/lib/filters/escape'
import { promisify } from 'bluebird'
import { readFile } from 'fs-promise'
// ===================================================================
@ -14,6 +13,22 @@ const bind = (fn, thisArg) => function () {
const noop = () => {}
export const promisify = (fn, thisArg) => function () {
const { length } = arguments
const args = new Array(length + 1)
for (let i = 0; i < length; ++i) {
args[i] = arguments[i]
}
return new Promise((resolve, reject) => {
args[length] = (error, result) => error
? reject(error)
: resolve(result)
fn.apply(thisArg || this, args)
})
}
// -------------------------------------------------------------------
const VAR_RE = /\{\{([^}]+)\}\}/g