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

Redefine reference methods #8

Open
d3x0r opened this issue Nov 16, 2020 · 0 comments
Open

Redefine reference methods #8

d3x0r opened this issue Nov 16, 2020 · 0 comments

Comments

@d3x0r
Copy link
Owner

d3x0r commented Nov 16, 2020

Right now, a refererence tag is an internal type called ref that uses array revival for something like ref['path','to','data',0] which starts at the root of the object and recursively follows the object by field..

var obj = rootObject; // array or object root object of the JSOX result

for( path in refPath ) { // ['path','to','data',0]
    obj = obj[path]; 
}

// obj at this point will point to the specified object.

References can ONLY refer to things that have already been encoded, there are no future references.

During the process of reviving an object, based on comments made here

This means sometimes the objects don't yet exist in the real output object yet; so revisions had to be made to trace the active context stack following along until the temporary internal object is found, before it's linked into the resulting output object.

Idea

node.js/v8 util.format() for an object mark cyclic structures with <ref:1> and <ref:*1> (or something like that. This means that during stringification; previously computed string values have to be updated to include a reference to be later used, because when the object is stringified at a particular point, the reference can be used instead of showing the object's content.

However, such tags are much more brief; and through a large and twisted objects the current path notations may be a significant potion of increased size.

Intent

I suppose, I could also revisit the external usage API and allow specific user hooks to encode such things; the stringify IS kept in a array of strings that is joined as a concatenation, so it could be possible to prefix some thing(s)?

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

No branches or pull requests

1 participant