Utility functions for Node.js and JavaScript
Helper and utility functions for Node.js.
Installation ·
Docs ·
API
Follow @marcuspoehls and @httpiejs for updates!
---
@httpie/utilities package provides a handful of useful helper functions for Node.js and JavaScript, like an async tap function.```
npm i @httpie/utilities
in the extensive httpie docs. is pretty straightforward. The package exports a handful of methods that you can reach for when requiring the package:
#### tap(value, callback)
Returns the
value after running the callback. The callback receives the value as an argument.`js
const { tap } = require('@httpie/utilities')return tap(await User.find(1), async (user) => {
await user.subscribeToNewsletter()
})
// returns the user with ID 1
`
#### upon(value, callback)
Returns the result of the callback. The callback receives the value as an argument.
`js
const { upon } = require('@httpie/utilities')return upon(await User.find(1), async (user) => {
return user.email
})
// user@email.com
`
Contributing
Do you miss a goodie function? We very much appreciate your contribution! Please send in a pull request 😊1. Create a fork
2. Create your feature branch:
git checkout -b my-feature
3. Commit your changes: git commit -am 'Add some feature'
4. Push to the branch: git push origin my-new-feature`---
> httpiejs.com ·
> GitHub @httpie ·
> Twitter @httpiejs