New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

glob-esm-graph

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glob-esm-graph

Generate ESM dependencies graph by glob-matching

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

glob-esm-graph

Match files by glob pattern and generate their dependencies graph.

Install

npm install glob-esm-graph

# or

yarn add glob-esm-graph

# or

pnpm install glob-esm-graph

API

globMatch

type Options = {
  /**
   * The current working directory in which to search.
   */
  cwd: string,
  /**
   * Glob patterns to match against.
   */
  pattern: string | string[],
}

declare function globMatch (options: Options): string[]

Input the work dir and the glob pattern(s), returns the matched files in under dependent modules.

analyze

type DependenciesAnalysis = { module: string, dependencies: string[]}

declare function analyze(entries: string[], cwd: string): Promise<DependenciesAnalysis[]>

Input the esm format files as entries and the work dir, returns the analysis which contain the module info and their dependencies info.

buildGraph

type Graph = {
  getNodes: () => string[],
  getEdges: () => [from: string, to: string][],
  getEntryNodes: () => string[],
  getEndNodes: () => string[],
  getPaths: () => string[][],
  getCircular: () => string[][],
  getSortedByDependencies: () => string[][],
}

declare function buildGraph (dependenciesAnalysis: DependenciesAnalysis[]): Graph

Input the dependencies analysis comes from analyze, returns the graph stats.

  • getPaths doesn't contains circular paths
  • getSortedByDependencies will sort the dependencies which are related and keep the other's original order. The sorting priority accords to dependent depth in the graph.

Usage

import { globMatch, analyze, buildGraph } from 'glob-esm-graph'

const cwd = `${__dirname}/foo-test`
const pattern = '**/*.module.ts'

const matched = globMatch({ cwd, pattern })
const dependenciesAnalysis = await analyze(matched, cwd)
const graph = buildGraph(dependenciesAnalysis)

Keywords

FAQs

Package last updated on 05 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc