# ng-dependencies

> > Analyze javascript code using [esprima](https://github.com/ariya/esprima) and return a list of objects representing the module dependencies in the code.

Latest version **0.8.1** (published 2016-08-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng-dependencies
pnpm add ng-dependencies
yarn add ng-dependencies
bun add ng-dependencies
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.1 |
| Published | 2016-08-08 |
| First published | 2014-04-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Maintainers | brian.lai, joakimbeng |
| Keywords | angularjs, modules, dependency |

## Links

- npm: https://www.npmjs.com/package/ng-dependencies
- Repository: https://github.com/klei/ng-dependencies
- Homepage: https://github.com/klei/ng-dependencies#readme
- Issues: https://github.com/klei/ng-dependencies/issues
- npm.io page: https://npm.io/package/ng-dependencies

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.0.0
- [esprima](https://npm.io/package/esprima.md) ^2.6.0
- [estraverse](https://npm.io/package/estraverse.md) ^4.2.0

## Recent versions

- 0.8.1 (latest) — 2016-08-08
- 0.8.0 — 2016-07-20
- 0.7.0 — 2016-07-05
- 0.6.0 — 2016-07-05
- 0.5.0 — 2016-02-16
- 0.4.0 — 2016-01-12
- 0.3.0 — 2015-09-25
- 0.2.0 — 2015-02-15
- 0.1.3 — 2014-11-19
- 0.1.2 — 2014-09-03
- 0.1.1 — 2014-07-29
- 0.1.0 — 2014-04-25
- 0.0.1 — 2014-04-09

## README

#ng-dependencies

> Analyze javascript code using [esprima](https://github.com/ariya/esprima) and return a list of objects representing the module dependencies in the code.

This is based on [gulp-angular-filesort](https://github.com/klei/gulp-angular-filesort). I extracted the module dependency code because I need to find a way to dynamically generate a root angular module that depends on a list of angular modules as Bower packages.

### Usage
```js
var fs = require('fs');
var ngDeps = require('ng-dependencies');

var deps = ngDeps(fs.readFileSync('./someNgModule.js'));

console.log(deps);
```

If the content of `./someNgModle.js` is as following:
```js
angular.module('test', ['one']).run(function () {
  // run some logic
});
angular.module('another', []);
angular.module('another').Controller('Ctrl', ['$scope', function ($scope) {
  // some controller logic
}]);
angular.module('useThis').run(function () {
  // ...
});
```

This will output:
```js
{
  dependencies: ['one', 'useThis'],
  modules: {
    'test': ['one'],
    'another': []
  }
}
```

### Special Cases
If multiple declarations of the same module is encountered, (according to [Angular Doc](https://docs.angularjs.org/guide/module)), the later declaration will overwrite any existing module that is declared with the same module name.

For example, the following content:
```js
angular.module('test', ['one']);
angular.module('test', ['another']);
```

will output:
```js
  {
    dependencies: ['another'],
    modules: {
      'test': ['another']
    }
  }
```

### Change log

0.1.1 - fixing repo url in `package.json` and removing unnecessary dependency.

0.1.0 - simplified output format; added detection for angular.js itself.

---
_Source: https://npm.io/package/ng-dependencies · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
