Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about modules which are functions with properties? #13

Open
fabiosantoscode opened this issue Apr 6, 2015 · 1 comment
Open

How about modules which are functions with properties? #13

fabiosantoscode opened this issue Apr 6, 2015 · 1 comment

Comments

@fabiosantoscode
Copy link

If I have a module mymodule which exports a function with properties, as follows:

module.exports = function mymodule() { /* ... */ }
module.exports.foo = 1

How am I supposed to "statify" it, without choosing whether to restrict my client code to use either the function or the properties?

// Case 1: statify the function
staticModule({
    mymodule: function () { return '"something"' }
})  // Bad! cannot access require('mymodule').foo

// Case 2: statify the props
staticModule({
    mymodule: {
        foo: function() { return '1' }
    }
})  // Bad! cannot call require('mymodule')()

My use case is my project over at fabiosantoscode/require-emscripten, which is a node module exporting a function which also has properties.

@cancerberoSgx
Copy link

same here, I want to use a module that exports just a function : require('my-module')('use', 'no', 'properties', 'exported') - Fortunately the project is mine so I'm also exporting a property - but for users it could be confusing. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants