Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juliangruber/module-usage
See how a module is used in npm.
https://github.com/juliangruber/module-usage
Last synced: 4 days ago
JSON representation
See how a module is used in npm.
- Host: GitHub
- URL: https://github.com/juliangruber/module-usage
- Owner: juliangruber
- Created: 2013-12-22T16:52:49.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-04-15T17:45:34.000Z (over 1 year ago)
- Last Synced: 2024-10-30T00:37:52.483Z (14 days ago)
- Language: JavaScript
- Size: 190 KB
- Stars: 19
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# module-usage
See how a module is used in npm.
## Example
```js
var usage = require('module-usage')
var name = process.argv[2] || 'intersect'usage(name).on('data', function(u) {
console.log('%s (%s)', u.dependant, u.file)
console.log()
console.log(indent(u.code))
console.log()
});function indent(txt) {
return txt.replace(/^/gm, ' ')
}
```Some usages of [intersect](http://npmjs.org/intersect):
```bash
$ node example.js intersect
bower-json (lib/util/isComponent.js)var intersect = require('intersect');
bower-json (lib/util/isComponent.js)
common = intersect(keys, [
'repo',
'development',
'local',
'remotes',
'paths',
'demo'
]);roole-prefixer (lib/LinearGradientPrefixer.js)
var intersect = require('intersect');
roole-prefixer (lib/LinearGradientPrefixer.js)
var prefixes = intersect(this.prefixes, [
'webkit',
'moz',
'o'
]);...
```Some usages of [mkdirp](http://npmjs.org/mkdirp):
```bash
$ node example.js mkdirp
ae86 (lib/engine.js)var mkdirp = require('mkdirp');
ae86 (lib/engine.js)
mkdirp(p.join(dir, page).replace(/(\/[^\/]+$|\\[^\\]+$)/, ''), '0755', function (err) {
'callback...';
});
amerigo (vespucci.js)var mkdirpSync = require('mkdirp').sync;
amerigo (vespucci.js)
mkdirpSync(folderpath);
amerigo (pvespucci.js)
mkdirpSync(padpath);
```
## API
### usage(name[, opts])
Create a readable stream that emits usage objects with keys
* `dependant`: The name of the module depending on `name`
* `file`: The path of the file where `name` is used
* `code`: The line where `name` is used
* `node`: The ast node where `name` is used, generated by [esprima](http://npmjs.org/esprima)Pass `opts.registry` to overwrite the default npm registry location.
## CLI
```bash
$ npm install -g module-usage
$ module-usage intersect
```## Installation
```bash
$ npm install module-usage
```## License
MIT