Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const defaultArgs = {
- like: false
- }
- const dependencies = {
- goToExternalService: require('pathToExternalService')
- }
- //a binary function...
- /*The first argument is a JSON as the list of arguments*/
- /*The second argument is the injection*/
- function foo(args, injection) {
- const { language, like } = Object.assign({}, defaultArgs, args) //do not use args directly
- const { goToExternalService } = Object.assign({}, dependencies, injection) //neither injection
- return goToExternalService(language, like)
- }
- //...consumed as unitary!
- foo({ language: 'js', like: true })
- foo({ language: 'c#', like: true })
- foo({ language: 'java' })
Add Comment
Please, Sign In to add comment