Closed boxofrox closed 9 years ago
One thing I would like input on. Is there a preference for how IIFE are used?
Look at the test suite for local collections and note that I have two IIFEs, one for server code and the other for client code. I considered using one IIFE for the whole file, but figured two emphasized the server vs client code better.
I added the IIFEs to keep local vars out of the global scope. Maybe the IIFEs are unncessary with the var
keyword. If so, let me know.
Edit: IIRC, javascript will hoist variables to the top of their scope, which before ES6 if
blocks have no scope boundaries. So without two IIFEs, I may end up creating unused variables in both server and client environments.
Oh, I think it's probably unnecessary because Meteor wraps each of your files in an IIFE anyway (try viewing source in the browser). Unless I'm misunderstanding (highly possible).
That's right. /facepalm. And only the variable declaration is hoisted, not the assignment. So I don't need either IIFE. Thanks, @tmeasday.
I'm travelling the next two days, so I'll merge and publish this PR now.
Code reviews welcome. Will wait a day or two in case @dburles has any input regarding #61 .
To test local collections, I only duplicated the basic count test suite. I didn't feel there was sufficient difference between the operation of basic count, countFromField, and countFromFieldLength to warrant duplicating the test suites for the latter two. If anyone prefers I add the extra tests, let me know.
I intend to publish this fix in release/0.7.1, if acceptable.
Fixes #61