javascript - Extend lodash/underscore on node.js? -
lodash , underscore have method called mixin allow extend libraries. how write library extend them?
for example, if created file called "extend_lodash.js", following content:
_.mixin({ new_function:function(){} }) how work on project? code below won't work:
_ = require("lodash"); require("extend_lodash.js");
as 'mu short' suggests, have file lodash mixin return lodash.
in "extend_lodash.js" file:
var _ = require('lodash'); _.mixin({ new_function:function(){} }); module.exports = _; and in caller, require mixin , lodash that:
var _ = require("extend_lodash");
Comments
Post a Comment