Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement safer map
  • Loading branch information
dominictarr committed May 10, 2014
1 parent 5e5ede8 commit e570532
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions throughs.js
Expand Up @@ -9,9 +9,15 @@ var tester = u.tester
var map = exports.map =
function (read, map) {
map = prop(map) || id
return function (end, cb) {
read(end, function (end, data) {
var data = !end ? map(data) : null
return function (abort, cb) {
read(abort, function (end, data) {
try {
data = !end ? map(data) : null
} catch (err) {
return read(err, function () {
return cb(err)
})
}
cb(end, data)
})
}
Expand Down

0 comments on commit e570532

Please sign in to comment.