404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.144.94.197: ~ $
'use strict'

const fs = require('fs')
const stream = require('stream')

const parse = require('./parser')

const stringify = require('./stringifier')

module.exports = parse

module.exports.stringify = stringify

/* ------- Transform stream ------- */

class Parser extends stream.Transform {
  constructor (opts) {
    opts = opts || {}
    super({ objectMode: true })
    this._extract = parse.mkextract(opts)
  }

  _transform (data, encoding, done) {
    let block
    const lines = data.toString().split(/\n/)

    while (lines.length) {
      block = this._extract(lines.shift())
      if (block) {
        this.push(block)
      }
    }

    done()
  }
}

module.exports.stream = function stream (opts) {
  return new Parser(opts)
}

/* ------- File parser ------- */

module.exports.file = function file (file_path, done) {
  let opts = {}
  const collected = []

  if (arguments.length === 3) {
    opts = done
    done = arguments[2]
  }

  return fs.createReadStream(file_path, { encoding: 'utf8' })
    .on('error', done)
    .pipe(new Parser(opts))
    .on('error', done)
    .on('data', function (data) {
      collected.push(data)
    })
    .on('finish', function () {
      done(null, collected)
    })
}

Filemanager

Name Type Size Permission Actions
.github Folder 0755
.vscode Folder 0755
.editorconfig File 243 B 0644
.eslintignore File 15 B 0644
.eslintrc.json File 142 B 0644
CHANGELOG.md File 2.34 KB 0644
LICENSE File 1.06 KB 0644
README.md File 7.42 KB 0644
index.d.ts File 7.26 KB 0644
index.js File 1.2 KB 0644
package.json File 2 KB 0644
parser.js File 7.21 KB 0644
parsers.js File 2.85 KB 0644
stringifier.js File 1.77 KB 0644