-
Notifications
You must be signed in to change notification settings - Fork 35
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
added functions to iterate on objects #7
added functions to iterate on objects #7
Conversation
Thanks for taking the time to contribute! ❤️ First things first: this should go into a category of its own: Other than that, instead of So ideally, these would just be wrappers around
Sounds great! Please make them separate PRs though. ;) |
…are now wrappers to Object.values() and Object.entries()
* ``` | ||
*/ | ||
export function * keys () : Iterable<String> { | ||
yield* Object.keys(this); |
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.
Elsewhere in codebase the spacing with yield*
is yield *
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.
also, four space indentation
Sorry to nitpick about code style, haven't had the time to setup JSCS for the project yet, and unfortunately JSCS doesn't even have rules for a lot of things in the codebase yet. :) Looks good otherwise! |
* @example Basic Usage | ||
* | ||
* ```javascript | ||
* {a:1,b:2,c:3}::pairs() |
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.
This should be entries
.
ahhh, i feel your pain ;P |
Sorry, and thanks for your patience! :D ❤️ Actually just re-checked the Flow docs and it should be |
/** | ||
* Yields entries of the bound object. | ||
* | ||
* @this {Object<T>} |
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.
Back to {Object}
:D
haha... i'm today just to fast at pushing ... i drank to much coffee, i guess... |
happens to the best of us :D |
Awesome, thank you! ❤️ 👍 🎉 |
added functions to iterate on objects
In my opinion, a must have for trine.
This enables us to work with objects in an idiomatic way;
Let's get rid of this cumbersome Object.keys(obj) and replace it with:
I think a excellent source of inspiration is python's itertools...
In my next commit i'd like to introduce enumerate, zip, and some other functions