<commit_before>var EventEmitter = require('events').EventEmitter
var inherits = require('util').inherits
var merge = require('xtend')
var Transform = require('stream').Transform
var util = require('levelup/lib/util')

var Batch = require('./batch')
var Namespace = require('./namespace')

module.exports = Bytespace

function getCallback (opts, cb) {
  return typeof opts == 'function' ? opts : cb
}

function getOptions(opts) {
  return merge(util.getOptions(opts))
}

// create a bytespace within a remote levelup instance
function Bytespace(db, ns, opts) {
  if (!(this instanceof Bytespace))
    return new Bytespace(db, ns, opts)

  if (!(ns instanceof Namespace)) {

    // if db is a subspace mount as a nested subspace
    if (db.namespace instanceof Namespace)
      return db.sublevel(ns, opts)

    // otherwise it's a root subspace
    ns = new Namespace([ ns ], opts && opts.hexNamespace)
  }

  var space = this

  space.namespace = ns
  opts = space.options = merge(Bytespace.options, db.options, opts)
  ns.createCodec(opts)

  // use provided methods manifest in options or get from db
  space.methods = merge(opts.methods || db.methods)

  // forward `open` and `close` events from base db
  var events = [ 'open', 'close' ]
  events.forEach(function (event) {
    db.on(event, space.emit.bind(space, event))
  })

  // proxy `isOpen` to underlying db
  space.isOpen = function () {
    return db.isOpen()
  }

  // set multilevel `isClient` boolean
  space.isClient = !!db.isClient<commit_msg>Bump maxListeners of underlying db<commit_after>var EventEmitter = require('events').EventEmitter
var inherits = require('util').inherits
var merge = require('xtend')
var Transform = require('stream').Transform
var util = require('levelup/lib/util')

var Batch = require('./batch')
var Namespace = require('./namespace')

module.exports = Bytespace

function getCallback (opts, cb) {
  return typeof opts == 'function' ? opts : cb
}

function getOptions(opts) {
  return merge(util.getOptions(opts))
}

// create a bytespace within a remote levelup instance
function Bytespace(db, ns, opts) {
  if (!(this instanceof Bytespace))
    return new Bytespace(db, ns, opts)

  if (!(ns instanceof Namespace)) {

    // if db is a subspace mount as a nested subspace
    if (db.namespace instanceof Namespace)
      return db.sublevel(ns, opts)

    // otherwise it's a root subspace
    ns = new Namespace([ ns ], opts && opts.hexNamespace)
  }

  var space = this

  space.namespace = ns
  opts = space.options = merge(Bytespace.options, db.options, opts)
  ns.createCodec(opts)

  // use provided methods manifest in options or get from db
  space.methods = merge(opts.methods || db.methods)

  // forward `open` and `close` events from base db
  var events = [ 'open', 'close' ]
  events.forEach(function (event) {
    db.setMaxListeners(db.getMaxListeners() + 2)
    db.on(event, space.emit.bind(space, event))
  })

  // proxy `isOpen` to underlying db
  space.isOpen = function () {
    return db.isOpen()
  }

  // set multilevel `isClient` boolean
  space.isClient = !!db.isClient
{'fraction_non_alphanumeric': 0.1250808015513898, 'fraction_numerical': 0.0003232062055591467, 'mean_word_length': 3.7179878048780486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '386723', 'n_tokens_mistral': 953, 'n_tokens_neox': 930, 'n_words': 297}