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

add array bracket notation support #73

Closed
wants to merge 3 commits into from
Closed

add array bracket notation support #73

wants to merge 3 commits into from

Conversation

mreinstein
Copy link

@mreinstein mreinstein commented Nov 3, 2020

this works now:

const obj = { a: [ { b: 'cool' } ]};
const val = dotProp.get(obj, 'a[0].b'); // val === 'cool'


const fixture3 = {a: [{b: 'cool'}]};
t.is(dotProp.get(fixture3, 'a[0].b'), 'cool');
t.is(dotProp.get(fixture3, 'a[1].b', 'defaultVal'), 'defaultVal');
Copy link
Owner

Choose a reason for hiding this comment

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

Try to come up with some more assertions. For example, a[0].nonexistant with and without default value.

@sindresorhus
Copy link
Owner

Also see #71

@sindresorhus
Copy link
Owner

sindresorhus commented Nov 3, 2020

This will need docs and more tests (for each method).

@mreinstein
Copy link
Author

mreinstein commented Nov 3, 2020

Also see #71

Yeah, I saw that when looking through back issues to see if this was brought up anywhere. The title of 71 matches what this PR does, but the content of the issue seems somewhat unrelated (claims to backwards incompatibility breaks and other stuff)

This will need docs and more tests (for each method).

I didn't do the additional tests in the PR because all of the public methods (get, set, has) use the same underlying getPathSegments to resolve the path, so they seemed redundant. That said I'm happy to add them if you really feel those tests aren't redundant. Can you give me a sense of the depth of testing you want for each public method?

@mreinstein
Copy link
Author

I have significantly underestimated the complexity of making this change. :(

@mreinstein mreinstein closed this Nov 5, 2020
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