Warning: mitsuketa project is no longer maintained in favor of @enio.ai/data-ferret.
Thanks for using this project. If you have concerns or need help with migration, you can leave a comment or question on enio's discussion board.
Mitsuketa 
A Javascript library that enables you to handle deeply nested objects easily.
Installation
Using npm: ``` $ npm i -g npm $ npm i --save mitsuketa ```Why mitsuketa?
Mitsuketa makes JavaScript easier by taking the hassle out of working with deeply nested data structures. Allows you to strict compare object, locate deeply nested entities, etc.Lastest Release Notes
- Two new features have been released. deepRemoveKey, deepRemoveAllKey to remove the properties or keys of any simple or deeply nested object on the fly!
- Great News! As part of the effort to further improve documentation, next Monday, we are releasing a playground website. What you can do there is visualize data and interact with mitsuketa. To learn more of how we are achieving this, you can check out mitsuketa's sister project React JSON Editor.
- Up until recently, most of the features have focused on obtaining data from complex object trees. Now we are taking an exciting new focus on actual deeply nested object manipulation. Check out our project board for a sneak peek to the new features. Feel free suggest any feature that you'd like to see by answering the survey down below.
- If you haven't checked it out already, you can learn more about how we set up and execute tests.
Overview
| Method | Brief Description | Parameters/Input | Output | | ------------- |-----------------------------| ------| :-----:| | getType | Getstypeof
identity
also makes distinction between object
, null
, and array
| identity | string |
| sameType | Compares two identities
using getType
method | identityA, identityB | identity
or false
|
| sameStructure | Compares two identities
using sameType
then validates both have the same keys
| identityA, identityB | identity
or false
|
| identical | Compares two identities
using sameStructure
then validates children or nested structures for iterble identities
or actual values
| identityA, identityB | identity
or false
|
| isIterable | Checks if identity
contains one or more keys or properties | identity | boolean |
| containsKeys | Checks if identity
contains the specified properties | identity, keyList | boolean |
| trim | Removes properties from identity
and only keeps the specified properties | identity, keyList | identity
|
| locate | Performs a deep search by iterating through the collection
's entire object tree an returns the path to the first identical
match that is found as a string of dot . separated property names | collection, identity | string |
| deepGet | Uses locate
and returns the indentity
's container if found in collection
| collection, identity | identity |
| locateAll | Uses locate
and returns all the paths to all matches | collection, identity | array of string |
| deepFilter | Uses locateAll
and returns an array of all an identites matched inside collection
| collection, identity | array of identities |
| length | Returns the number of keys or properties contained in identity
| identity | number |
| exists | Performs deep search on collection
for an identical
match to identity
| collection, identity | boolean |
| onlyExisting | For each identity in identities
, performs a deep search on collection
using exists
, to shorten the list identities
to those that were found | collection, identities | identities |
| onlyMissing | For each identity in identities
, performs a deep search on collection
using exists
, to shorten the list identities
to those that were not found | collection, identities | identities |
| isFalsy | Checks if identity has or false or false-like values. These include: null, undefined, '', false, and 0 | identity | identity
or false
|
| isTruthy | Checks if identity is non-falsy | identity | identity
or false
|
| foundTruthy | Performs deep search on collection
, and evaluate if isTruthy
on the first identical match to identity
| collection, identity | boolean |
| foundFalsy | Performs deep search on collection
, and evaluate if isFalsy
on the first identical match to identity
| collection, identity | boolean |
| onlyTruthy | For each identity in identities
, performs a deep search on collection
using exists
, and evaluates if isTruthy
on the first identical match of property
to shorten the list identities
to those that were found and also truthy | collection, identities, property | identities |
| onlyFalsy | For each identity in identities
, performs a deep search on collection
using exists
, and evaluates if isFalsy
on the first identical match of property
to shorten the list identities
to those that were found and also truthy | collection, identities, property | identities |
| countMatches | Performs deep search for identity
on collection
using locateAll
and returns the number of confirmed matches in a given depth | collection, identity, number | number |
| maxDepth | Returns the nth value of the deepest layer of the entire object tree | identity | number |
| matchDepth | Performs deep search for identity
on collection
to return the location's depth of the first match. If no match found, returns false. | collection, identity | number |
| locateKey | Performs a deep search by iterating through the collection
's entire object tree an returns the path to the first identical
match that is found as a string of dot . separated property names | collection, key | string |
| deepGetKey | Uses locate_Key
and returns the indentity
's container if found in collection
| collection, key | identity |
| locateAllKey | Uses locate_Key
and returns all the paths to all matches | collection, key | array of string |
| deepFilterKey | Uses locateAll
and returns an array of all an identites matched inside collection
| collection, key | array of identities |
| deepClone | Creates a non-reference clone that is an exact copy to the identity provided. Can be used to create shallow clones
of specific depths. Can also be used to create branch clones
. Read more in documentation | collection, key | any |
| renameKey | Performs deep search on the identity
's object tree to rename the first matching key. | identity, key, key | identity |
| renameKeys | Performs deep search on the identity
's object tree to rename all matching keys. | identity, key, key | identity |
| deepRemoveKey | Performs deep search on the identity
's object tree to remove the first property with matching key. | identity, key | identity |
| deepRemoveAllKey | Performs deep search on the identity
's object tree to remove all properties with matching key. | identity, key | identity |
Built With
- Vanilla Javascript, ES5, ES6
Authors
- Andrew Redican andrewredican
License
This project is licensed under the MIT License - see the LICENSE.md file for details.Acknowledgments
- Got my inspiration from lodash.js