build/bin/run/extract.js
async function extractTypedef(config) {
  const {
    source,
    destination,
    writable,
  } = config
  try {
    const s = createReadStream(source)
    const ts = createRegexTransformStream(typedefRe)
    const ps = new Properties()
    const readable = new PassThrough()
    const xml = new XML()

    await writeOnce(readable, '<types>\n')

    s.pipe(ts).pipe(ps).pipe(xml).pipe(readable, { end: false })

    const p = whichStream({
      readable,
      source,
      writable,
      destination,
    })

    await new Promise((r, j) => {
      s.on('error', e => { LOG('Error in Read'); j(e) })
      ts.on('error', e => { LOG('Error in Transform'); j(e) })
      ps.on('error', e => { LOG('Error in RegexTransform'); j(e) })
      xml.on('error', e => { LOG('Error in XML'); j(e) })
      readable.on('error', e => { LOG('Error in Stream'); j(e) })
      xml.on('end', r)
    })

    await new Promise(r => readable.end('</types>\n', r))
    await p
  } catch (err) {
    catcher(err)
  }
}
async function extractTypedef(config) {
  const {
    source,
    destination,
    writable,
  } = config
  try {
    const s = createReadStream(source)
    const ts = createRegexTransformStream(typedefRe)
    const ps = new Properties()
    const readable = new PassThrough()
    const xml = new XML()

    await writeOnce(readable, '<types>\n')

    s.pipe(ts).pipe(ps).pipe(xml).pipe(readable, { end: false })

    const p = whichStream({
      readable,
      source,
      writable,
      destination,
    })

    await new Promise((r, j) => {
      s.on('error', e => { LOG('Error in Read'); j(e) })
      ts.on('error', e => { LOG('Error in Transform'); j(e) })
      ps.on('error', e => { LOG('Error in RegexTransform'); j(e) })
      xml.on('error', e => { LOG('Error in XML'); j(e) })
      readable.on('error', e => { LOG('Error in Stream'); j(e) })
      xml.on('end', r)
    })

    await new Promise(r => readable.end('</types>\n', r))
    await p
  } catch (err) {
    catcher(err)
  }
}
async function extractTypedef ( config ) { const { source , destination , writable , } = config try { const s = createReadStream ( source ) const ts = createRegexTransformStream ( typedefRe ) const ps = new Properties ( ) const readable = new PassThrough ( ) const xml = new XML ( ) await writeOnce ( readable , '<types>\n' ) s . pipe ( ts ) . pipe ( ps ) . pipe ( xml ) . pipe ( readable , { end : false } ) const p = whichStream ( { readable , source , writable , destination , } ) await new Promise ( ( r , j ) => { s . on ( 'error' , e => { LOG ( 'Error in Read' ) ; j ( e ) } ) ts . on ( 'error' , e => { LOG ( 'Error in Transform' ) ; j ( e ) } ) ps . on ( 'error' , e => { LOG ( 'Error in RegexTransform' ) ; j ( e ) } ) xml . on ( 'error' , e => { LOG ( 'Error in XML' ) ; j ( e ) } ) readable . on ( 'error' , e => { LOG ( 'Error in Stream' ) ; j ( e ) } ) xml . on ( 'end' , r ) } ) await new Promise ( r => readable . end ( '</types>\n' , r ) ) await p } catch ( err ) { catcher ( err ) } }
Process a JavaScript file to extract typedefs and place them in an XML file.
@param {Config} config Configuration object.
@param {string} config.source Input file from which to extract typedefs.
@param {string} [config.destination="-"] Output file to where to write XML. `-` will write to `stdout`. Default `-`.
@param {string} [config.stream] An output stream to which to write instead of a location from `extractTo`.
Process a JavaScript file to extract typedefs and place them in an XML file .