I want to convert require( "./handlers/event.js")(client)
to es6 but can't find how to do it.
CodePudding user response:
That line is importing from a module that looks like this
module.exports = function(client) {
this.newClient = function() {
var x = client()
// ...
}
}
Which in ES6 would look like this
export default function(client) {
this.newClient = function() {
var x = client()
// ...
}
return this
}
For importing that in an ES6 way, should be something like
import FOO from "./handlers/event"
And then you can do something like
const { newClient } = FOO(new Client())
const p = newClient() // or anything you want to do with it