git ssb

2+

Dominic / pull-stream



Tree: 7aa21412f6c0bd6b84022d67ff8e51711eddb510

Files: 7aa21412f6c0bd6b84022d67ff8e51711eddb510 / map.js

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

Built with git-ssb-web