5 ms·
Show HN: namespace.js - a 250 byte open source project.
- mckoss 16y agoI wish there was more uniformity with the way JavaScript libraries manage the global namespace. So, I stripped down the library I use to the bare essentials, and made it a stand-alone open source (public domain) project. I'm hoping that by removing the idiosyncrasies of my earlier version, I can actually get others to adopt this mechanism. Is it crazy to have such a tiny open source project? (BTW: the gzipped/minified version of the library is less than 250 bytes - hence the title).
- jrockway 16y agoIs it crazy to have such a tiny open source project? Not particularly. Who cares how much or how little code there is, if it does the job?
- reinhardt 16y agoNot crazy but probably an overkill. I'd just post it as a gist.
- mckoss 16y agoSince I want this evangelize this to others, making a full repo lets me put in a nice read me, make it clear the license is in the public domain, and also provide unit tests.
- Semiapies 16y agoI'm intrigued; I'll have to try it out.
- pcwalton 16y agoNote that my colleague Dave Herman (on the TC39 committee; i.e. the JavaScript standards committee) is working on an official modules proposal for the next version of JavaScript, code-named Harmony. See here for examples: http://wiki.ecmascript.org/doku.php?id=strawman:simple_modules_examples http://wiki.ecmascript.org/doku.php?id=strawman:simple_modul...
- calebmpeterson 16y agoI like it for how single-minded it is. Do one thing and do it well. Here's my one question (and it's not specific to namespace.js) How to do imports so I can avoid var obj = new namespace.com.foo.bar.baz.FooBar(...);
- mckoss 16y agoI will generally have an "imports" type line at the top of my module, and then use the abbreviated name in the code. This is similar to Python's "from module import name" pattern. var library = namespace.com.foo.bar.baz; ... var obj = new library.FooBar(); It's generally considered a best practice (in the Python community) to leave the external module name (like "library", above) so that someone reading your code can recognize which functions are external to your module, and which ones are local.
- calebmpeterson 16y agoThanks for the input!
- mckoss 16y agoUpdate: I added a project web site with a FAQ here: http://mckoss.github.com/namespace/ http://mckoss.github.com/namespace/