@depanlz/core
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.9 • Public • Published

@depanlz/core

这个模块在项目依赖分析中扮演着核心角色,集成了关键的依赖分析功能,将各种依赖分析的任务统一在一个模块中。

DepAnlz 类

declare class DepAnlz {
    depth: number;
    constructor(depth: number);
    preHook(): Config;
    coreHook(config: Config): DepGraph;
    postHook(callback: (config:Config, depGraph: DepGraph) => any): any;
    lifeCycle(): DepGraph;
}

DepAnlz类是我们分析项目依赖的核心,我们可以通过DepAnlz实例对象身上的一些Hook方法,来定制化个人的依赖分析行为。

快速上手

下载

$ npm install @depanlz/core
$ pnpm add @depanlz/core 
$ yarn add @depanlz/core 

构建实例

有关 typescript 的类型声明

type Config = {
    PKG_JSON_DIR: string,
    NODE_MODULES_DIR: string,
    PKG_MANAGER: string,
    DEPTH: number
}

type DepNode = {
    id: string,
    dependence: string,
    version: string,
    level: number
}

type DepRel = {
    source: string,
    target: string
}

declare class DepGraph {
    nodes: Array<DepNode>;
    edges: Array<DepRel>;
    constructor();
    insertEgde(fromNodeId: string, toNodeId: string): void;
    insertNode(dependence: string, version: string, level: number):void ;
}

使用 DepAnlz 类构建实例,以及进行依赖分析,加工处理等。

import { DepAnlz, Config, DepGraph } from "@depanlz/core"

const depth: number = 3

const anlz: DepAnlz = new DepAnlz(depth)

const config: Config = anlz.preHook()

const depGraph: DepGraph = anlz.coreHook(config)

function callback (config: Config, depGraph: DepGraph): void {
    console.log(config)
    console.log(depGraph)
}

anlz.postHook(callback)

Readme

Keywords

none

Package Sidebar

Install

npm i @depanlz/core

Weekly Downloads

2

Version

0.0.1-alpha.9

License

ISC

Unpacked Size

31.4 kB

Total Files

42

Last publish

Collaborators

  • scoheart