Skip to content

Instantly share code, notes, and snippets.

@corbanbrook
Last active December 1, 2015 16:32
Show Gist options
  • Save corbanbrook/fc5b1196aeec65655955 to your computer and use it in GitHub Desktop.
Save corbanbrook/fc5b1196aeec65655955 to your computer and use it in GitHub Desktop.
Find all occurances of lodash functions in a bundle
cat file.js | grep "[^_]_\.[[:alpha:]]" | sed "s/.*_\.\([[:alpha:]]*\)[^[:alpha:]].*/\1/g" | sort | uniq | xargs | sed "s/ /,/g"
Outputs list like:
all,any,camelCase,capitalize,chain,clone,compact,contains,debounce,defaults,detect,difference,each,extend,filter,find,findIndex,findWhere,first,flatten,functions,groupBy,indexOf,inject,isArray,isEmpty,isEqual,isFunction,isString,keys,last,map,memoize,merge,pick,pluck,pull,reduce,reject,remove,sample,select,sortBy,startsWith,throttle,times,toArray,union,uniq,where,zip
Which can be sent to lodash-cli to create a custom build
lodash include=...
Or you can just do it all in one line:
cat file.js | grep "[^_]_\.[[:alpha:]]" | sed "s/.*_\.\([[:alpha:]]*\)[^[:alpha:]].*/\1/g" | sort | uniq | xargs | sed "s/ /,/g" | sed "s/^/include=/" | xargs lodash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment