3 ms·
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', [
by thekaleb 12y ago
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;
};
});