Skip to content

Commit 5da09ab

Browse files
committed
feat: add named exports
Exposing the various types and classes for programatical usage with a shortcut for the complexity calculation. This should give a decent support for functional or object-oriented support while keeping the changes low. refs: simonrenoult#8
1 parent 007438e commit 5da09ab

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ Note: `code-complexity` currently measures complexity using either:
2626
$ npx code-complexity <path-to-git-directory or URL> [options]
2727
```
2828

29+
or
30+
31+
```javascript
32+
// CommonJS
33+
const complexity = require("code-complexity")
34+
const results = await complexity.compute({
35+
target: "some/file/path"
36+
})
37+
```
38+
39+
```typescript
40+
// ES Modules
41+
import { analyize } from "code-complexity";
42+
43+
const results = await analyize({
44+
target: "some/file/path"
45+
})
46+
```
47+
2948
## Help
3049

3150
```text

src/lib/index.ts

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
import Statistics from "./statistics/statistics";
2+
import Churns from "./churn/churns";
3+
import Complexities from "./complexity/complexities";
24

5+
// Expose shared type interfaces
6+
export * from "./types";
7+
8+
// For CommonJS support: require("code-complexity")
39
export default Statistics;
10+
11+
// For ESM functional-style support: import { analyize } from "code-complexity";
12+
export const analyize = Statistics.compute;
13+
export const analyise = Statistics.compute;
14+
15+
// For ESM object-style: `import { Statistics } from "code-complexity"`
16+
export {
17+
Statistics,
18+
// Expose these as they are dependencies for Statistics
19+
Churns,
20+
Complexities,
21+
};
File renamed without changes.

0 commit comments

Comments
 (0)