mirror of
https://github.com/Instadapp/Swap-Aggregator-Subgraph.git
synced 2024-07-29 21:57:12 +00:00
24 lines
484 B
JavaScript
24 lines
484 B
JavaScript
'use strict'
|
|
|
|
function id (e) { return e }
|
|
var prop = require('../util/prop')
|
|
|
|
module.exports = function map (mapper) {
|
|
if(!mapper) return id
|
|
mapper = prop(mapper)
|
|
return function (read) {
|
|
return function (abort, cb) {
|
|
read(abort, function (end, data) {
|
|
try {
|
|
data = !end ? mapper(data) : null
|
|
} catch (err) {
|
|
return read(err, function () {
|
|
return cb(err)
|
|
})
|
|
}
|
|
cb(end, data)
|
|
})
|
|
}
|
|
}
|
|
}
|