News for hackers. Stuff that matters.
Re:Why do we need modules at all? (2011) by thekaleb on Friday November 07, 2014 @05:00PM (#8574880)
I use requirejs for module loading and for my personal projects try to limit each module to a single function. Contrived example:

    define('object/clone', ['object/each'], function(each) {
        /**
         * Shallow copy objects
         *
         * @param {object} - object from which to copy properties
         * @return shallow copy of `obj`
         */
        return function(obj) {
            var clone = {};
            each(obj, function(key, value) {
                clone[key] =  value;
            });
            return clone;
        };
    });

There are no comments on this comment yet.