Cannot call a class as a function
<p>Is there any way that would allow me to call a class as a function. I'm looking to have the functionality below, where there's a <code>main</code> method within the class and that's the one I want to have the method execute.</p>

<pre><code>class test {
  constructor () {
    return this.main
  }
  main () {
    return Promise.resolve('thomas')
  }
}

test().then(name =&gt; {
  console.log(name)
})
</code></pre>

<p>It seems my only other option would be to have a wrapper function like this.</p>

<pre><code>class Test {
  constructor (name) {
    this.name = name
  }
  main () {
    return Promise.resolve(this.name)
  }
}

let test = (name) =&gt; {
  return new Test(name).main()
}

test('thomas').then(name =&gt; {
  console.log(name)
})
</code></pre>