lodash unsetCompact

node v8.17.0
version: 1.0.0
endpointsharetweet
_ = require('lodash') _.mixin({ unsetCompact: (object, path) => { const parentPath = path.slice(0,path.lastIndexOf('.')); _.unset(object, path); _.update(object, parentPath, _.compact); } }); x = {a: {b: [[5,6,7,8, null], [1,2,3,4], [10, undefined, 11],]}}; _.unsetCompact(x, 'a.b.1.1'); console.log(x)
Loading…

no comments

    sign in to comment