Update sea.js

This commit is contained in:
Mark Nadal 2018-02-26 13:16:56 -08:00 committed by GitHub
parent d8dd8f11f0
commit 20284e18c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
sea.js
View File

@ -669,23 +669,30 @@
}
// then figuring out all possible candidates having matching username
const aliases = []
let c = 0
// TODO: how about having real chainable map without callback ?
Gun.obj.map(rat.put, (at, pub) => {
if (!pub.slice || 'pub/' !== pub.slice(0, 4)) {
// TODO: ... this would then be .filter((at, pub))
return
}
++c
// grab the account associated with this public key.
gunRoot.get(pub).get((at, ev) => {
root.get(pub).get((at, ev) => {
pub = pub.slice(4)
ev.off()
--c
if (at.put){
aliases.push({ pub, at })
}
if (!c && (c = -1)) {
resolve(aliases)
}
})
})
return !aliases.length ? reject({ err: 'Public key does not exist!' })
: resolve(aliases)
if (!c) {
reject({ err: 'Public key does not exist!' })
}
})
})
module.exports = queryGunAliases