<commit_before>'use strict'
const Bluebird = require('bluebird')
const Readable = require('readable-stream').Readable

class FicStream extends Readable {
  constructor (fic, options) {
    if (!options) options = {}
    options.objectMode = true
    if (!options.highWaterMark) options.highWaterMark = 4
    super(options)
    this.FicStream = {
      reading: false,
      chapterBuffer: [],
      readyP: null,
      readyR: null
    }
    // ficstreams are also fics
    for (let pp in fic) {
      if (this[pp] != null) continue
      if (typeof fic[pp] === 'function') {
        const method = fic[pp]
        this[pp] = function () { return method.apply(fic, arguments) }
      } else {
        Object.defineProperty(this, pp, {
          get: () => fic[pp]
        })
      }
    }
  }
  queueChapter (chapter) {
    const state = this.FicStream
    if (state.reading) {
      state.reading = this.push(chapter)
      if (chapter == null) return Bluebird.resolve()
    } else {<commit_msg>fic-stream: Fixup property/method proxying to source fic<commit_after>'use strict'
const Bluebird = require('bluebird')
const Readable = require('readable-stream').Readable

function proxy (from, prop, to) {
  if (to[prop] != null) return
  if (typeof from[prop] === 'function') {
    const method = from[prop]
    to[prop] = function () { return method.apply(from, arguments) }
  } else {
    Object.defineProperty(to, prop, {
      get: () => from[prop]
    })
  }
}

class FicStream extends Readable {
  constructor (fic, options) {
    if (!options) options = {}
    options.objectMode = true
    if (!options.highWaterMark) options.highWaterMark = 4
    super(options)
    this.FicStream = {
      reading: false,
      chapterBuffer: [],
      readyP: null,
      readyR: null
    }
    // ficstreams also proxy everything from their source fic
    for (let pp in fic) {
      proxy(fic, pp, this)
    }
    for (let pp of Object.getOwnPropertyNames(Object.getPrototypeOf(fic))) {
      proxy(fic, pp, this)
    }
  }
  queueChapter (chapter) {
    const state = this.FicStream
    if (state.reading) {
      state.reading = this.push(chapter)
      if (chapter == null) return Bluebird.resolve()
    } else {
{'fraction_non_alphanumeric': 0.127996381727725, 'fraction_numerical': 0.0009045680687471732, 'mean_word_length': 2.723905723905724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6384642', 'n_tokens_mistral': 706, 'n_tokens_neox': 697, 'n_words': 182}