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

getValueByKey looks broken #2395

Closed
asvae opened this issue Sep 14, 2022 · 0 comments · Fixed by #2429
Closed

getValueByKey looks broken #2395

asvae opened this issue Sep 14, 2022 · 0 comments · Fixed by #2429
Assignees
Labels
BUG Something isn't working d2: easy Recomended mode for new, but mature players implementation Requires implementation

Comments

@asvae
Copy link
Member

asvae commented Sep 14, 2022

export const getValueByKey = <T extends (string | number | Record<string, unknown>)> (
  option: T,
  prop: string | ((option: T) => any),
): any => {
  // Can't access not object option
  if (typeof option !== 'object' || !option) { return undefined } // Option can be array, string, symbol, Date or anything else. 

  if (!prop) { return option }
  if (typeof prop === 'string') { return getValueByPath(option, prop) }
  if (typeof prop === 'function') { return prop(option) }
  return option // What is this line doing?
}
@asvae asvae added BUG Something isn't working team discussion Feedback wanted d2: easy Recomended mode for new, but mature players implementation Requires implementation and removed team discussion Feedback wanted labels Sep 14, 2022
@aluarius aluarius self-assigned this Sep 21, 2022
aluarius added a commit to aluarius/vuestic-ui that referenced this issue Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG Something isn't working d2: easy Recomended mode for new, but mature players implementation Requires implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants