Last active
August 29, 2015 14:10
-
-
Save ideodora/051b6af17069ca99425e to your computer and use it in GitHub Desktop.
module.exports で インスタンスとクラス両方返す方法?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// export the function that instantiate the class and return it with same option | |
module.exports = function foo(opts) { | |
return new Foo(opts); | |
}; | |
module.exports.Foo = Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = require('foo') // foo is isntance | |
var Foo = require('foo').Foo // Foo is class | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment