My JavaScript book is out! Don't miss the opportunity to upgrade your beginner or average dev skills.

Thursday, October 06, 2011

implicit require in node.js

playing with Harmony Proxy I came out with a simple snippet:


The aim of above snippet is to forget the usage of require ... here some example:

module.sys.puts("Hello implicit require");

var fs = module.fs;
fs.stat( ... );

It's compatible with nested namespaces too and if there are non JS chars in the middle ... well:
var Proxy = module["node-proxy"];

1 comment:

Anonymous said...

Clever but doesn't actually save any typing...