var rest = require('../src/function/rest')

function ensureAsync (fn) {
  return rest(function(args) {
    var callback = args.pop()

    args.push(function () {
      var innerArgs = arguments
      if (sync) {
        process.nextTick(function () {
          callback.apply(null, innerArgs)
        })
      } else callback.apply(null, innerArgs)
    })
    var sync = true
    fn.apply(this, args)
    sync = false
  })
}

module.exports = ensureAsync

@@ -20,12 +20,8 @@
 '../
-src/
 func

fix require path