git ssb

2+

Dominic / pull-stream



Tree: 9d9abd26492b94a6b650b38e7db4ef41257d64d7

Files: 9d9abd26492b94a6b650b38e7db4ef41257d64d7 / throughs / map.js

484 bytesRaw
1'use strict'
2
3function id (e) { return e }
4var prop = require('../util/prop')
5
6module.exports = function map (mapper) {
7 if(!mapper) return id
8 mapper = prop(mapper)
9 return function (read) {
10 return function (abort, cb) {
11 read(abort, function (end, data) {
12 try {
13 data = !end ? mapper(data) : null
14 } catch (err) {
15 return read(err, function () {
16 return cb(err)
17 })
18 }
19 cb(end, data)
20 })
21 }
22 }
23}
24

Built with git-ssb-web