io.scalajs.npm.csvparse.package.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of csv-parse_sjs0.6_2.11 Show documentation
Show all versions of csv-parse_sjs0.6_2.11 Show documentation
csv-parse binding for Scala.js
package io.scalajs.npm
import io.scalajs.RawOptions
import io.scalajs.nodejs.Error
import io.scalajs.util.PromiseHelper._
import scala.concurrent.Promise
import scala.scalajs.js
import scala.scalajs.js.|
/**
* csv-parse package object
* @author [email protected]
*/
package object csvparse {
type CsvResults = js.Array[js.Array[String]]
/**
* Csv-Parse Events
* @param parser the given [[CsvParse parser]] instance
*/
implicit class CsvParseEvents(val parser: CsvParse) extends AnyVal {
@inline
def parseFuture(text: String, options: ParserOptions | RawOptions = null): Promise[CsvResults] = {
promiseWithError1[Error, CsvResults](parser.apply(text, options, _))
}
@inline
def onError(listener: Error => Any): parser.type = parser.on("error", listener)
@inline
def onFinish(listener: () => Any): parser.type = parser.on("finish", listener)
@inline
def onReadable(listener: () => Any): parser.type = parser.on("readable", listener)
}
}