Reputation: 95
Imagine I have this class:
class Class {
constructor(arg1, arg2) { arg1 = arg2};
}
Should I do this?
class Class = exports.Class {
constructor(arg1, arg2) { arg1 = arg2};
}
Or there's another way?
Upvotes: 0
Views: 184
Reputation: 350
You should do like this (for other ways, check @Snow answer):
class Class {
constructor(arg1, arg2) { arg1 = arg2};
}
module.exports = Class;
Upvotes: 2
Reputation: 4097
With export
syntax, just put export
before the class:
export class Class {
(this results in a named export named Class
)
Or, for a default export:
export default class Class {
With module
syntax, assign to module.exports
, or to a property of module.exports
:
module.exports = class Class {
or
module.exports.Class = class Class {
Upvotes: 2