_.mergeWith example

node v6.17.1
version: master
endpointsharetweet
var _ = require("lodash@4.16.4"); _.assign(global, require("lodash-doc-globals")); Object.observe = _.noop;
var a = { "rewrite": [ { "from": "/css/*", "to": "/build/styles/$1" }, { "from": "/npm/*", "to": "http://registry.npmjs.org/$1" }, { "from": "/:user/repos/:name", "to": "https://api.github.com/repos/:user/:name" } ] } var b = { "rewrite": [ { from: '/another', to: '/lib/another' } ] } function customiser(objValue, srcValue) { if (_.isArray(objValue)) { return objValue.concat(srcValue); } }   _.mergeWith(a, b, customiser);
Created from: https://lodash.com/docs/4.16.4#merge
Loading…

no comments

    sign in to comment