https://github.com/goldcaddy77/object-key-prefixer
:point_left: Namespace all keys in a javascript object by adding a prefix
https://github.com/goldcaddy77/object-key-prefixer
javascript json
Last synced: about 2 months ago
JSON representation
:point_left: Namespace all keys in a javascript object by adding a prefix
- Host: GitHub
- URL: https://github.com/goldcaddy77/object-key-prefixer
- Owner: goldcaddy77
- License: mit
- Created: 2017-03-02T06:45:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-31T19:27:37.000Z (over 9 years ago)
- Last Synced: 2025-02-09T00:32:07.433Z (over 1 year ago)
- Topics: javascript, json
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# object-key-prefixer
[](https://www.npmjs.org/package/object-key-prefixer)
[](https://standardjs.com)
## A JavaScript object key prefixer
A simple method that takes an object and returns a new object where all of the top-level keys have been prefixed by some string.
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#license)
## Install
```bash
npm install --save object-key-prefixer
```
## Usage
```javascript
var prefixer = require('object-key-prefixer');
var obj = {
one: 'foo',
two: {
bar: 'baz'
}
}
prefixer(obj, 'awesome_')
```
Output:
```javascript
{
awesome_one: 'foo',
awesome_two: {
bar: 'baz'
}
}
```
## Contribute
PRs accepted. Note that code uses [standard](https://github.com/feross/standard) styling.
## License
MIT © Dan Caddigan