<commit_before>package com.criteo.vizatra.vizsql.js

import com.criteo.vizatra.vizsql.DB
import com.criteo.vizatra.vizsql.js.json.DBReader

import scala.scalajs.js.Dynamic
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSExport, ScalaJSDefined}

@JSExport("VizSQL.Database")
object Database {
  @JSExport
  def from(input: Dynamic): DB = DBReader.apply(input)
}

@ScalaJSDefined
class Database(db: DB) extends js.Object {
  def parse(query: String) = {
    QueryParser.parse(query, db)
  }
}<commit_msg>[scala.js] update Database methods<commit_after>package com.criteo.vizatra.vizsql.js

import com.criteo.vizatra.vizsql.DB
import com.criteo.vizatra.vizsql.js.json.DBReader

import scala.scalajs.js.Dynamic
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSExport, ScalaJSDefined}

@JSExport("VizSQL.Database")
object Database {
  /**
    * Parses to a VizSQL DB object
    * @param input a JS object of the database definition
    * @return DB
    */
  @JSExport
  def parse(input: Dynamic): DB = DBReader.apply(input)

  /**
    * Construct a Database object from the database definition
    * @param input a JS object of the database definition
    * @return Database
    */
  @JSExport
  def from(input: Dynamic): Database = new Database(parse(input))
}

@ScalaJSDefined
class Database(db: DB) extends js.Object {
  def parse(query: String) = {
    QueryParser.parse(query, db)
  }
}
{'fraction_non_alphanumeric': 0.11252653927813164, 'fraction_numerical': 0.0, 'mean_word_length': 4.237037037037037, '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': '5998897', 'n_tokens_mistral': 507, 'n_tokens_neox': 499, 'n_words': 112}