-
Notifications
You must be signed in to change notification settings - Fork 99
[main] improve passing of input data to output #304
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
Conversation
|
Not sure if this is too simplistic. |
|
I don't think this is the right approach, as it means that you are modifying the original data object (to add in the defaults), which is not a good idea, and since that object is part of the calling code, it could be modified outside of mathJax-node before mathjax-node has processed it. That is one reason the mathjax-node currently copies the data rather than keep it directly. Instead, I'd recommend adding a copy of the data object to the information stored in the queue (at line 837), as and then at line 662 save the original as and return that at line 776 You will want to clear |
Right. But (Also, a separate PR may have been shorter 😉 ) |
Yes, but the only nested structure that is part of the If you want a deep copy, then use
but would not have constituted a code review, and would not have said why the changes were suggested, and would have required me to spend time testing it to make sure it works. So it would have been shorter for you, but longer for me. 🙂 |
|
@dpvc updated as per your suggestion. PTAL. |
lib/main.js
Outdated
| // | ||
| var item = queue.shift(); | ||
| data = item[0]; callback = item[1]; | ||
| data = item[0]; callback = item[1]; originalData = item[2]; |
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.
Can you remove the leading space that was added?
lib/main.js
Outdated
| if (data.state) {options.state = data.state} | ||
| if (!TYPES[options.format]) {ReportError("Unknown format: "+options.format,callback); return} | ||
| queue.push([options,callback]); | ||
| queue.push([options,callback,Object.assign({},data)]); |
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.
Also here?
|
Other than the unwanted spaces, I think it is OK. |
|
LGTM |
zorkow
left a comment
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.
General remark on tests:
I think eventually they should be combined into a dedicated test runner, to avoid duplication and maintenance costs.
| // | ||
| var item = queue.shift(); | ||
| data = item[0]; callback = item[1]; | ||
| data = item[0]; callback = item[1]; originalData = item[2]; |
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.
Don't double park instructions.
| if (data.state) {options.state = data.state} | ||
| if (!TYPES[options.format]) {ReportError("Unknown format: "+options.format,callback); return} | ||
| queue.push([options,callback]); | ||
| queue.push([options,callback,Object.assign({},data)]); |
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.
Object.assign is ES6. Is that intended?
|
@zorkow Where's this coming from? This PR has already been reviewed by @dpvc so I wasn't planning any more change (just delaying for another bug fix release before a feature release with this).
Please file an issue. (Though, as you know, I don't see the need at this point.)
Let's please do a style clean-up some other time. A separate issue might be good.
Since Node v4 supports it (cf. the passing test), I don't see an issue. |
Resolves #303
|
Ok, sorry for the mess of half-borked branches while working out that my local develop branch had been screwed up. This is now a clean new branch off develop with the same changes as an "earlier" commit. I've now fixed two things I missed from @dpvc's earlier suggestion -- declaring and clearing |
|
@dpvc if you can take another look just for sanity's sake, I'd appreciate it. These are the same changes (plus two things I overlooked from your earlier recommendations). |
|
LGTM |
Resolves #303