Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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 ....

milahu added 4 commits August 24, 2020 13:59
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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants