https://github.com/jucian0/object-path
An immutable implementation of dot-prop.
https://github.com/jucian0/object-path
imutability javascript tdd-javascript
Last synced: 3 months ago
JSON representation
An immutable implementation of dot-prop.
- Host: GitHub
- URL: https://github.com/jucian0/object-path
- Owner: jucian0
- Created: 2021-06-18T01:16:48.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-21T12:34:18.000Z (about 4 years ago)
- Last Synced: 2025-02-03T11:22:03.269Z (5 months ago)
- Topics: imutability, javascript, tdd-javascript
- Language: JavaScript
- Homepage:
- Size: 380 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Object Path - TDD implementation
## An immutable implementation of dot-prop

## Get, set, or delete a property from a nested object using a dot path
get(object, path, defaultValue?)
Get the value of the property at the given path.Returns a value if any.
```javascript
const obj = {
property: {
test: "A",
},
};const result = get(obj, "property");
```## Set the property at the given path to the given value.
set(object, path, value)
Returns a object.
```javascript
const obj = {
property: {
test: "A",
},
};const result = set(obj, "property", "B");
```## Delete the property at the given path.
delete(object, path)
Returns a object without the property deleted.
```javascript
const obj = {
property: {
test: "A",
},
};const result = del(obj, "property.test");
```## Merge the property that has an array or an object.
merge(object, path)
Returns a object with the property and value passed by argument merged.
```javascript
const obj = {
property: {
test: [1, 2],
},
};const result = merge(obj, "property.test", [3, 4]);
```## Run Tests
```bash
yarn test
```