Repository navigation
Conversation
|
By the way, if you're interested, I'd love to update your testing suite to mocha/chai. Besides all of the security warnings your old version of tap in producing, I went nuts tracking down the single original unit test that failed after I first made most of my code changes. The JavaScript source line numbers were way off, and breakpoint positions were wildly out of place. That made this one bug really hard to track down. I've already done the mocha/chai work in my own JSON5 fork, which I hadn't touched for nearly five years until this last month. My fork is a crazy excessive add-on to JSON5, which I'm pretty sure has no chance of catching on like JSON5, but it's my strange idea of fun anyway, and I like having it for myself. |
|
Very cool! Thank you for this contribution! =) @jordanbtucker: would love your 👀; curious if you have any concerns or if this LGTY too. Ditto on both counts for the offer to update our tests! |
|
By the way, I just got a PR for the highlight.js project accepted so that it now will recognize and highlight JSON5. |
…t to take advantage of source data.
|
@kshetline Thanks for your work on this. With the source text access at Stage 4, I'm happy to include this in JSON5. If you're still interested in merging this, it will need a bit of work since we just merged a bit of an overhaul to main. Let me know if you're interested in porting it. |
|
I'm glad to see that things have picked up here again. It'll take me a little while to remember where I left off, but yes, I can try to rework this PR to fit properly with the current state of the project. |
|
Awesome! Thanks for your support. Would you mind reviewing #386. It looks like this feature has already been ported onto main. |
Looks good to me. |
|
Superseded by #386 |
Closes json5#361. The parse loop has changed quite a lot since that PR was opened so its pretty much a full rework to add this feature either way. This adds support for `context.source` when using a reviver, just the same as `JSON.parse`. Note that this may look a bit funky but that's for performance reasons. Instead of allocating an AST-like set of objects to track position info, we hold a collection of slots. The slots collection looks like this: ```ts type PrimitiveSlot = [value: unknown, start: number, end: number]; type ChildMeta = Array<number> | Map<string, number> type ContainerSlot = [value: unknown, childMeta: ChildMeta, end: 0]; ``` This results in something like this: ```ts // {foo:303,bar:808} const slots = [ // {foo:303,bar:808} root, Map { foo: 3, bar: 6 }, 0, // 303 303, 5, 8, // 808 808, 13, 16 ]; ```
Closes json5#361. The parse loop has changed quite a lot since that PR was opened so its pretty much a full rework to add this feature either way. This adds support for `context.source` when using a reviver, just the same as `JSON.parse`. Note that this may look a bit funky but that's for performance reasons. Instead of allocating an AST-like set of objects to track position info, we hold a collection of slots. The slots collection looks like this: ```ts type PrimitiveSlot = [value: unknown, start: number, end: number]; type ChildMeta = Array<number> | Map<string, number> type ContainerSlot = [value: unknown, childMeta: ChildMeta, end: 0]; ``` This results in something like this: ```ts // {foo:303,bar:808} const slots = [ // {foo:303,bar:808} root, Map { foo: 3, bar: 6 }, 0, // 303 303, 5, 8, // 808 808, 13, 16 ]; ```

As I added to the README.md file: