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

User provided prototype encoder/decoders lack API #6

Closed
d3x0r opened this issue Nov 12, 2019 · 2 comments
Closed

User provided prototype encoder/decoders lack API #6

d3x0r opened this issue Nov 12, 2019 · 2 comments

Comments

@d3x0r
Copy link
Owner

d3x0r commented Nov 12, 2019

Internally there's support for the 'map' type.
This type looks a lot like any other object to JS; and can recursively encode itself using the same stringifier, which allows objects in the map to reference other objects, or be references for other objects, however, if this was implemented purely as a user-side method, it would lack the ability to put itself as a path member in the path array that tracks the current branch of the object. Objects encoded within this which are references will lack the contents of the object.

So, user objects which are circular maybe have issues.
This could have been solved in the map by encoding the content of the map object using a different stringifier(and different parser on the other side) so that the base of the references in that will be within the map-type object itself, however, this would prevent members of the map from referencing objects outside the map...

So probably some hooks should be added to the API to allow this; ATM I don't know what the shape of those will be.

@d3x0r
Copy link
Owner Author

d3x0r commented Nov 16, 2020

Generally objects are attempted to be collected entirely themselves; objects which have references will always be valid within the JSOX context itself without external reviver support; although an external reviver that does a value replacement should include the original objects from JSOX.

typed-array

the values in the array are all gathered until the closing ] and then the whole array is passed to the constructor arrayType in the following example.

arrayType[...] 

typed string

Recall that any non-control characters/non number leadin type value is a valid string without quotes...

string string2

"another example" "parameter"

// another common example [ object Object ] 
// the previous failes unless there is a type called 'object' registered.
// 

If there is no reviver registered, string-string class definitions will throw a value 'Double String s....' something. There's no way to make a prototype object dynamically, and is really a fault at conversion of the value into a JS value.

typed objects

Objects are created initially with new ObjectType() when the initial open object is created, this allows calling the optional callback with each field of the object being revived; so unlike the previous tagged types, this revives immediately instead of waiting for a gathered parameter.

The last time the type revive callback is called, the field is passed as undefined, allowing the object to replace itself entirely at the end... There is at least one case where storedObjectReaderType results with storedObjectType at the end, and after it additionally processes the information in the record to reload the object.

@d3x0r
Copy link
Owner Author

d3x0r commented Dec 21, 2020

@d3x0r d3x0r closed this as completed Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant