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 custome object #48

Open
harvey-woo opened this issue Apr 28, 2019 · 0 comments
Open

Support custome object #48

harvey-woo opened this issue Apr 28, 2019 · 0 comments

Comments

@harvey-woo
Copy link

harvey-woo commented Apr 28, 2019

Add support for serialization and deserialization of custom objects via Object.assign and Object.create
For example:

class A {
    a = 1
}
serialize(A, { classes: { A } })

get

const serialized = "(function(args) {var k = args[0].classes;return args[0].assign(Object.create(k.A.prototype), { a: 1 })})(arguments)"
function unserialize() {
    return eval(serialized)
}
unserialize({ classes: {A: function() {}}, assign: Object.assign })
@harvey-woo harvey-woo changed the title Support customer object Support custome object Apr 28, 2019
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