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

1.8.31 - fixes to lodash-es issues, added variable depth schemaPopulated population #262

Open
wants to merge 9 commits into
base: development
Choose a base branch
from

Conversation

bppdddqqqq
Copy link

@bppdddqqqq bppdddqqqq commented Feb 11, 2021

Please describe your change...

For schemaPopulated, it now takes additional input which is an Array<string | string[]>, if string, it keeps the former behaviour of the function, if string[], it crawls individual array items it launches a recurrent crawling algorithm.

Let array be a list of object keys yet not of array indexes.
Starting from the root of object try to find a path leading to the string value using the keys defined in the index, if an object value is an array, launch the algorithm on all array values and flatten the result. If the key value is incorrect, return an empty array. If the algorithm doesn't find the value with set keys, return an empty array. If the algorithm finds a string value regardless of the absolved depth, return the string as an array.

Example: for an object {'abc': [{'def': {'er': 'a'}},{'def': {'er': 'b'}}], 'def': 'bca', 'ghi': {'jkl': 'abc'}} on inputs

  • ['abc', 'def', 'er'] returns ['a','b']
  • ['def'] returns ['bca']
  • ['abc'] returns []
  • ['abc', 'def'] returns []
  • ['ghi', 'jkl'] returns ['abc']
  • ['ghi', 'jkl', 'ojm'] returns ['abc']
  • ['ghi'] returns []

@bppdddqqqq
Copy link
Author

note: i forgot to bump version for @factor/post, it also received some changes

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

Successfully merging this pull request may close these issues.

1 participant