https://github.com/invrs/camel-dot-prop-immutable
dot-prop-immutable w/ fuzzy matching
https://github.com/invrs/camel-dot-prop-immutable
immutable merge object
Last synced: 8 days ago
JSON representation
dot-prop-immutable w/ fuzzy matching
- Host: GitHub
- URL: https://github.com/invrs/camel-dot-prop-immutable
- Owner: invrs
- Created: 2018-01-18T03:49:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T02:06:57.000Z (about 8 years ago)
- Last Synced: 2025-02-08T12:25:48.212Z (over 1 year ago)
- Topics: immutable, merge, object
- Language: JavaScript
- Homepage:
- Size: 288 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# camel-dot-prop-immutable
This extension to [dot-prop-immutable](/debitoor/dot-prop-immutable) adds fuzzy matching.
| Props | Matches | Type |
| -------------- | ---------------------------- | ---------------- |
| `foo.bar.buzz` | `{ foo: { bar: { buzz } } }` | Default behavior |
| `foo.bar.buzz` | `{ foo: { barBuzz } }` | Collapse right |
| `foo.bar.buzz` | `{ fooBar: { buzz } }` | Collapse left |
### Example
```js
import dot from "camel-dot-prop-immutable"
dot.get(
{ foo: { bar: { buzz: "unicorn" } } },
"foo.bar.buzz"
)
//=> 'unicorn'
dot.get({ fooBar: { buzz: "unicorn" } }, "foo.bar.buzz")
//=> 'unicorn'
dot.get({ foo: { barBuzz: "unicorn" } }, "foo.bar.buzz")
//=> 'unicorn'
dot.get({ fooBarBuzz: "unicorn" }, "foo.bar.buzz")
//=> 'unicorn'
```
## Restrictions
Only collapse from left or right. Middle collapses like this will not work:
```js
dot.get({ foo: { barBuzz: { bang: "unicorn" } }, "foo.bar.buzz.bang")
//=> 'unicorn'
```
But these do:
```js
dot.get({ fooBar: { buzz: { bang: "unicorn" } }, "foo.bar.buzz.bang")
//=> 'unicorn'
dot.get({ foo: { bar: { buzzBang: "unicorn" } }, "foo.bar.buzz.bang")
//=> 'unicorn'
```