https://github.com/pgilad/find-used-lodash
Use esprima to find and detect used lodash packages
https://github.com/pgilad/find-used-lodash
Last synced: about 1 year ago
JSON representation
Use esprima to find and detect used lodash packages
- Host: GitHub
- URL: https://github.com/pgilad/find-used-lodash
- Owner: pgilad
- License: mit
- Created: 2014-02-22T17:10:28.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-05-22T17:27:13.000Z (about 11 years ago)
- Last Synced: 2025-05-09T02:16:05.573Z (about 1 year ago)
- Language: JavaScript
- Size: 258 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# find-used-lodash
> Use Esprima to find and detect used Lodash packages
[](https://npmjs.org/package/find-used-lodash)
[](https://npmjs.org/package/find-used-lodash)
[](https://travis-ci.org/pgilad/find-used-lodash)
Useful for preparing an array to pass to a build task in order to build only used packages.
* Please see [Lodash](http://lodash.com/) for usable packages.
* Checkout [Lodash custom build tool](http://lodash.com/custom-builds) for possible uses.
**Important notice** Chained Lodash packages are currently not detected.
## Install
```
npm install --save-dev find-used-lodash
```
## Example
### General Usage
```js
var findUsedLodash = require('find-used-lodash');
console.log(findUsedLodash('_.each(["a", "b"], doSomething)');
//=> ['each']
```
### Use in a build task (grunt,gulp)...
```js
var findUsedLodash = require('find-used-lodash');
var fileContents = fs.readFileSync('targetFile.js', 'utf8'); //or get it from file stream
var results = findUsedLodash(fileContents);
var commaResults = results.join(',');
//then execute lodash command line with **lodash include=commaResults**
```
## Options
```js
@param {String} jsFileContents - the js file contents as a string
@return {String[]} array of used Lodash packages.
```
## License
MIT @[Gilad Peleg](http://giladpeleg.com)