1
0
mirror of https://github.com/fuse-friends/fuse-native synced 2024-10-27 18:34:01 +00:00

Standardized

This commit is contained in:
Andrew Osheroff 2019-07-16 13:46:43 +02:00
parent 8fb3334d7a
commit b9d24f6812
5 changed files with 20 additions and 15 deletions

View File

@ -156,13 +156,18 @@ function wrapSafe (ops, timeout) {
const cb = arguments[arguments.length - 1]
var called = false
if (destroyed) {
if (!called) return cb(exports.EIO)
return
}
const idx = pending.indexOf(null)
const cbInfo = { cb, tick: 0 }
pending[idx === -1 ? pending.length : idx] = cbInfo
try {
op.apply(null, [...Array.prototype.slice.call(arguments, 0, -1), safeCb])
op(...[...Array.prototype.slice.call(arguments, 0, -1), safeCb])
} catch (err) {
if (!cb[TIMED_OUT] && !called) return cb(exports.EIO)
}