Skip to content

support retrieving all property values via ramda#4

Open
alexkolson wants to merge 5 commits intoalexbepple:masterfrom
HamburgChimps:all-properties-can-be-retrieved
Open

support retrieving all property values via ramda#4
alexkolson wants to merge 5 commits intoalexbepple:masterfrom
HamburgChimps:all-properties-can-be-retrieved

Conversation

@alexkolson
Copy link
Contributor

@alexkolson alexkolson commented Oct 3, 2019

This wasn't so much a problem with getting all properties but rather with the way getting all properties with ramda works and ramda internals. Ramda internaly checks to see if an argument is its internal placeholder thingy sometimes and to do that it looks to see if there is a property on the argument with the key @@functional/placeholder. This of course invokes the get trap and the unknown property error is thrown.

Quick fix is just to check if the property being asked for is the placeholder property and if so just short circuit. It feels a bit strange to be doing ramda specific checks but at the same time given the
functional nature of kiss and type i don't think its too terrible :)

I think maybe a refactored long-term solution would be a way to tell a type what properties are allowed to be undefined, or even better, for what properties traps should not be invoked.

so this wasnt so much a problem with getting all properties but rather with the way getting all properties with ramda works and ramda internals
ramda internall checks to see if an argument is its internal placeholder thingy soemtimes and to do that it looks to see if there is a propery on the argument
with the key "@@functional/placeholder". This of course invokes the get trap and the unkown property error is thrown. Quick fix is just to check if the property
being asked for is the placeholder property and if so just short circuit. It feels a bit strange to be doing ramda specific checks but at the same time given the
functional nature of kiss and type i dont think its too strange.
it('all props can be retrieved with ramda', () => {
const doesNotThrow = __.not(
__.throws(
__.typedError(TypeError, __.containsString('Unknown'))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to PR #2, what do you think about relaxing the assertion? How about just __.not(__.throws())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

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.

2 participants