Created
July 29, 2022 15:55
-
-
Save faustoct1/a3ed57e4d7d20ebf0ed21802d2d7dc00 to your computer and use it in GitHub Desktop.
Passar parâmetro para um require
This file contains hidden or 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
module.exports = (params) => { | |
const app = { | |
print: async () => { | |
console.log(params) | |
} | |
} | |
return app | |
} | |
This file contains hidden or 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
const params = {appName:'App test',description:'Passar params para um require', version:'1.0.0'} | |
const app = require('./app')(params) | |
const test = async () => { | |
app.print() | |
} | |
(async () => test())() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment