0.1.2 • Published 6 years ago

circular-dependency-analyzer v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

circular-dependency-analyzer npm codecov Build License

Detect modules with circular dependencies in files.

Installation

npm install circular-dependency-analyzer

// or

yarn install circular-dependency-analyzer

APIs

getFileRequiresStack

ParametersTypeDescription
dirstringdir is a directory based on process.cwd()
aliasobjectalias object's value is a directory or file based on process.cwd() too
ResultTypeDescription
stackobjectIt's an object with key(filepath). value(required filepath array), filepath is based on process.cwd(), besides, its /index and extname will be removed

getCircularReferences

ParametersTypeDescription
dirstringdir is a directory based on process.cwd()
aliasobjectalias object's value is a directory or file based on process.cwd() too
ResultTypeDescription
circularDependencies2 d arrayIt's a two-dimensional array, each item array represents a circular dependency

Examples

import { getFileRequiresStack, getCircularReferences } from 'circular-dependency-analyzer'

getFileRequiresStack('src')
getCircularReferences('src')

getFileRequiresStack('src', {
  fs: 'src/fs',
})
getCircularReferences('src', {
  fs: 'src/fs',
})

More examples you can find in tests dir.

Inspired or cp from