Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/modify-values
Modify the values of an object
https://github.com/sindresorhus/modify-values
Last synced: about 1 month ago
JSON representation
Modify the values of an object
- Host: GitHub
- URL: https://github.com/sindresorhus/modify-values
- Owner: sindresorhus
- License: mit
- Created: 2015-01-25T10:37:53.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2021-09-10T05:19:12.000Z (about 3 years ago)
- Last Synced: 2024-04-13T16:33:38.384Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 28
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
README
# modify-values
> Modify the values of an object
## Install
```
$ npm install modify-values
```## Usage
```js
import modifyValues from 'modify-values';modifyValues({foo: 'UNICORN'}, (value, key) => value.toLowerCase());
//=> {foo: 'unicorn'}
```## API
### modifyValues(object, transformer)
Modifies the values and returns a new object.
#### object
Type: `object`
#### transformer(value, key)
Type: `Function`
Gets the value and key for each item and is expected to return the new value.
## Related
See [`modify-keys`](https://github.com/sindresorhus/modify-keys) for modifying the keys of an object.
---
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.