git ssb

3+

cel / ssb-npm-registry



Tree: 4f27567900a7b5b821bccc74e95bfc96c8233159

Files: 4f27567900a7b5b821bccc74e95bfc96c8233159 / node_modules / pull-stream / 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