Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eachDeep with childrenPath == wrong parent, parent path etc #143

Open
alexNecroJack opened this issue Mar 24, 2023 · 0 comments
Open

eachDeep with childrenPath == wrong parent, parent path etc #143

alexNecroJack opened this issue Mar 24, 2023 · 0 comments

Comments

@alexNecroJack
Copy link

I will start by saying, THANK YOU(!) for this great library (the Deepdash part of Loadash).

I have a simple structure,

window.inheritanceTree = {
    "variable": {
        "0": "string",
        "number": {
            "0": "int",
            "1": "float",
            "2": "double",
            "decimal": [
                "float",
                "double"
            ]
        }
    },
    "0": "template",
    "1": "view",
    "2": "data"
};

And then I make a simple call:
_.eachDeep(window.inheritanceTree, function(){console.log(arguments)}, {childrenPath: ['variable.number.decimal']});

The expected output for "float" for example would be: Arguments[2] == Array(2)['float', 'double']
or even: Arguments[2] == Object{0: 'int', 1: 'float', 2: 'double', 'decimal': Array[...]}

But instead I get:
Arguments[2] == Object{0: 'template', 1: 'view', 2: 'data', "variable": {...} }
which is the object I passed to _eachDeep in the first place...

I guess it has to do with how depth is calculated, that 'float' is in depth 1 under 'childrenPath', and that confuses the code to return the root element... But that's only a speculation after seeing a little the code of _eachDeep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant