-
Notifications
You must be signed in to change notification settings - Fork 457
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
Add Dict.has & improve Dict helpers performance #7316
base: master
Are you sure you want to change the base?
Conversation
@@ -29,7 +29,7 @@ let forEach = (dict, f) => { | |||
} | |||
|
|||
let forEachWithKey = (dict, f) => { | |||
dict->toArray->Stdlib_Array.forEach(((key, value)) => f(value, key)) | |||
dict->keysToArray->Stdlib_Array.forEach(key => f(dict->getUnsafe(key), key)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.keys(dict).forEach(key => { | ||
let value = dict[key]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks a lot!
target[key] = f(value); | ||
}); | ||
return target; | ||
} | ||
|
||
let has = ((dict, key) => key in dict); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we want to use hasOwnProperty
there?
No description provided.