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

support arbitrary keys #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

milahu
Copy link

@milahu milahu commented Aug 24, 2020

now users must append jsonMap.leaf_node to their keyList like

const jsonMap = require('json-source-map');
const result = jsonMap.parse('{"z":1,"a":{"z":1,"a":1}}');
const keyList = ['z', 'a']; // before this was ptr = '/z/a'
let pointer = result.pointers;
for (let key of keyList.concat([jsonMap.leaf_key])) {
  pointer = pointer[key];
}
const [a, b] = [pointer.value.pos, pointer.valueEnd.pos];

edit: forgot keyList = .... in commit message

edit: the constant should not be called leaf_key, rather loc_key

todo: tests ....

now users must append `jsonMap.leaf_node` to their `keyList` like

```js
const jsonMap = require('json-source-map');
const result = jsonMap.parse('{"z":1,"a":{"z":1,"a":1}}');
let pointer = result.pointers;
for (let key of keyList.concat([jsonMap.leaf_key])) {
  pointer = pointer[key];
}
const [a, b] = [pointer.value.pos, pointer.valueEnd.pos];
```
@coveralls
Copy link

Coverage Status

Coverage decreased (-18.5%) to 81.495% when pulling 37dd775 on milahu:patch-1 into 3e58861 on epoberezkin:master.

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.

None yet

2 participants