Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1x 1x 1x 1x 1x 1x 2x 2x 1x 1x 2x 1x 1x 5x 1x 4x 3x 2x 1x | /** * Including available read/input methods */ const fs = require('fs'); const { htmlTo$ } = require('../utils'); const eos = require('end-of-stream'); const readFromFile = (path, cb) => { return cb(htmlTo$(fs.readFileSync(path))); } const readFromStream = (stream, cb) => { let html = ''; eos(stream, (err) => { Iif (err) console.log('Read stream error', err.toString()); cb(htmlTo$(html.toString())) }); stream.on('data', (chunk) => { html += chunk.toString(); }) } module.exports = function(input = '', cb = () => {}) { if (typeof input === 'string') { return cb(htmlTo$(input)); } if (input instanceof Object) { if (input.file) return readFromFile(input.file, cb); Eif (input.stream) return readFromStream(input.stream, cb); } return cb(htmlTo$('<body></body>')); } |