https://github.com/sdgluck/expand-top-level-dot-paths
Expand top-level object properties that are dot-paths
https://github.com/sdgluck/expand-top-level-dot-paths
Last synced: 9 months ago
JSON representation
Expand top-level object properties that are dot-paths
- Host: GitHub
- URL: https://github.com/sdgluck/expand-top-level-dot-paths
- Owner: sdgluck
- Created: 2017-08-11T13:03:19.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-11T13:14:08.000Z (almost 9 years ago)
- Last Synced: 2025-08-11T21:35:20.670Z (10 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# expand-top-level-dot-paths
> Expand top-level object properties that are dot-paths
## Install
```sh
npm install --save expand-top-level-dot-paths
```
```sh
yarn add expand-top-level-dot-paths
```
## Import
```js
// ES2015
import expand from 'expand-top-level-dot-paths'
```
```sh
// CommonJS
var expand = require('expand-top-level-dot-paths')
```
## Usage
### `expand(obj[, initialValue]) : Object`
Expand top-level object properties that are dot-paths. If no `initialValue`
given the initial value is a clone of the object. In this case all original dot-path
properties are removed from the clone.
- __obj__ {Object} (required) The object to expand
- __initialValue__ {Object} (optional) Value to place expanded properties on (default: clone of `obj`)
Returns `initialValue` with all top-level dot-path properties from `obj` expanded on it.
#### Example
```js
const obj = {
'expand.me': 'please'
}
const expanded = expand(obj)
//=> {
// expand: {
// me: 'please'
// }
// }
obj === expanded //=> false
````
## Contributing
All pull requests and issues welcome!
If you're not sure how, check out the [great video tutorials on egghead.io](http://bit.ly/2aVzthz)!
## License
MIT © [Sam Gluck](github.com/sdgluck)