Skip to content

Commit

Permalink
Merge pull request #7 from webKrafters/readme
Browse files Browse the repository at this point in the history
Readme
  • Loading branch information
steveswork authored Jan 8, 2025
2 parents 3f62360 + 0de554d commit fc983dc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const property = getProperties(data, path, defaultValue?); // => PropertyInfo
<i>[optional]</i>
</td>
<td>
Value property to return if data a tproperty path is either not found or <code>null</code> or <code>undefined</code>.
Value property to return if data at property path is either not found or <code>null</code> or <code>undefined</code>.
</td>
<td>Any</td>
<td>Undefined</td>
Expand Down Expand Up @@ -169,6 +169,48 @@ const property = getProperties(data, path, defaultValue?); // => PropertyInfo
</tbody>
</table>
## Example:
```jsx
import getProperties from '@webkrafters/get-property';

const source = {
address: {
city: 'Test City',
state: 'My Province'
},
matrix: [
[ [ 0, 3, 1 ], [ 4, 0, 3 ] ],
[ [ 4, 1, 9 ], [ 7, 4, 9 ] ],
[ [ 8, 7, 3 ], [ 0, 3, 1 ] ]
],
registered: {
time: new Date(),
timezone: 'Eastern Time'
},
tags: [ 'test', 'foo', 'bar', 'baz', 'boo', 'tap', 'bak' ]
};

const property = getProperties(
source,
'registered.timezone',
'Mountain Time'
);
// returns property info object => {
// _value: 'Eastern Time',
// exists: true,
// index: undefined,
// isSelf: false,
// key: 'timezone',
// source: {
// time: new Date(),
// timezone: 'Eastern Time'
// },
// trail: [ 'registered', 'timezone' ],
// value: 'Eastern Time'
// }
```
<br /> <br />
# License
MIT
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@
"test:watch": "eslint --fix && jest --watchAll"
},
"types": "dist/index.d.ts",
"version": "1.1.2"
"version": "1.1.3"
}

0 comments on commit fc983dc

Please sign in to comment.