Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added relative path get and set#16

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ruisilva450 wants to merge1 commit intog-makarov:main
base:main
Choose a base branch
Loading
fromruisilva450:add-relative-set-get-by-patch

Conversation

@ruisilva450
Copy link

I'm coming from a specific use case on my side where I have an initial path and want to manipulate the object with a relative path from the initial.
After getting it working I thought it could be useful to include it on your package.

Explanation

We are going to start with this object:

constobj={a:{b:'hello',d:[{e:'world',},],},};

This PR is composed into two parts:

getByRelativePath(obj, path, relativePath)

  1. I know the initial path'a.d.0'
  2. I want toget the value that's relative to the initial path../../b
  3. I callgetByRelativePath(obj, 'a.d.0', '../../b')
  4. It should be able to step back twice ('../../' takes the context toa) and step forward once ('b' takes the context toa.b)
  5. I'm expected to get'hello'

setByRelativePath(obj, path, relativePath, value)

  1. I know the initial path'a.d.0'
  2. I want toset the value that's relative to the initial path../../b
  3. I callsetByRelativePath(obj, 'a.d.0', '../../b', 'good morning')
  4. It should be able to step back twice ('../../' takes the context toa) and step forward once ('b' takes the context toa.b)
  5. I'm expectedobj.a.b === 'good morning'

Note: Take into account that I'm not well knowledgeable in typescript and learned a good deal with your code. Still I know there is some work to be done on this PR related with that.

Can I get some help on that maybe? :)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@ruisilva450

[8]ページ先頭

©2009-2025 Movatter.jp