https://github.com/NickGard/tiny-get
A minimal-weight lodash.get equivalent utility
https://github.com/NickGard/tiny-get
Last synced: about 2 months ago
JSON representation
A minimal-weight lodash.get equivalent utility
- Host: GitHub
- URL: https://github.com/NickGard/tiny-get
- Owner: NickGard
- License: mit
- Created: 2018-12-02T03:56:09.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-09-27T20:46:02.000Z (over 2 years ago)
- Last Synced: 2025-09-25T22:24:29.203Z (4 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 6
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-web-dev-resources - tiny-get - weight lodash.get equivalent utility (Framework agnostic packages / General utilities)
README
# tiny-get
[](https://www.npmjs.com/package/@ngard/tiny-get)
[](https://bundlephobia.com/result?p=@ngard/tiny-get)
[](https://travis-ci.org/NickGard/tiny-get)
[](https://badgen.net/badge/license/MIT/blue)
A minimal-weight utility similar to `lodash.get`. For when every byte counts!
lodash.get [](https://bundlephobia.com/result?p=lodash.get)
tiny-get [](https://bundlephobia.com/result?p=@ngard/tiny-get)
## Syntax
```js
get(/* root, path [, default] */)
```
## Parameters
`root` - An object or array to traverse
`path` - A string of the path, or an array of property names to be traversed
`default` - [optional] A value to be returned if the path does not exist or results in an undefined value
## Return
The value found at the path on the root object or array, if it exists. If the path is invalid or results in
an undefined value, then `tiny-get` will return `undefined` or the default value if passed.
## Example
```javascript
import { get } from '@ngard/tiny-get';
const value = get(baseObj, 'really.deep.value', 'defaultValue');
const value = get(baseObj, 'really["deep"].value', 'defaultValue');
const value = get(baseObj, ['really', 'deep', 'value'], 'defaultValue');
```