Files: 1f9a3fcaa6f6fa4a3ad0a219f6df1a476588f6d5 / 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