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

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -