Files: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3 / node_modules / pull-utf8-decoder / index.js
545 bytesRaw
1 | |
2 | var Decode = require('string_decoder').StringDecoder |
3 | |
4 | module.exports = function (enc) { |
5 | var decoder = new Decode(enc), ended |
6 | return function (read) { |
7 | return function (abort, cb) { |
8 | if(ended) return cb(ended) |
9 | read(abort, function (end, data) { |
10 | ended = end |
11 | if(true === end) { |
12 | if(data = decoder.end()) cb(null, data) |
13 | else cb(true) |
14 | } |
15 | else if(end && (true !== end)) |
16 | cb(end) |
17 | else |
18 | cb(null, decoder.write(data)) |
19 | }) |
20 | } |
21 | } |
22 | } |
23 |
Built with git-ssb-web