-
Notifications
You must be signed in to change notification settings - Fork 26
support function & class #13
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
Open
lwdgit
wants to merge
6
commits into
skeeto:master
Choose a base branch
from
lwdgit:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lwdgit
commented
Apr 3, 2017
- support function & class
- add amd & cmd wrap for convience
Owner
|
Thanks for taking the time to put this together.
The lack of support for functions is intentional. It's not possible to
serialize closures and there's no way to discern a function that closes
over an environment from one that does not — meaning the error would be
completely silent. Rather than quietly screw up in some situations, I
chose not to allow it at all.
I don't use NPM so I don't know the situation there. As far as I can
tell it's already packaged? Does the package.json you added provide
anything useful or new? I'm willing to accept this new metadata (with
the correct license and URL) if it makes things easier for NPM.
https://www.npmjs.com/package/resurrect-js
I'm not interested in an AMD wrapper. I never liked it in the first
place — it conflicts with the way I use ResurrectJS — and with ES6
modules it's now a dead end.
|
Author
|
I write a test, and it seems ok! var Resurrect = require('resurrect.js')
var necromancer = new Resurrect();
var namespace = {};
namespace.Foo = function() {
this.bar = true;
this.getBar = function() {
return this.bar;
}
this.setBar = function(value) {
return this.bar = value;
}
};
namespace.Foo2 = class {
constructor() {
this.init();
}
init() {
this.inited = true
}
}
var foo_dead = necromancer.stringify(namespace);
var foo_undead = necromancer.resurrect(foo_dead);
var ins = new foo_undead.Foo();
console.log(ins.bar); // true
ins.setBar(false);
console.log(ins.getBar()); // false
var cls = new foo_undead.Foo2();
console.log(cls.inited); // trueyes, class only support es6 |
amir-arad
reviewed
Jun 20, 2017
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/lwdgit/resurrect-js.git" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should replace lwdgit with skeeto (also in two other github urls below)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.