Code Monkey home page Code Monkey logo

hound-trace's Introduction

Welcome to hound-trace 👋

JS call stack visualization JS 调用栈可视化工具

安装

安装 babel-plugin-hound-trace

因为 hound-trace 实现原理是在函数中注入代码(无变量接收的函数表达式、匿名函数已过滤),所以需要配套安装此插件:

yarn babel-plugin-hound-trace -D  # npm install babel-plugin-hound-trace -D

安装后需要在你的 babelplugins 配置项中添加该插件,比如使用的是 .babelrc 配置的,则添加的配置如下:

{
    "presets": ["@babel/preset-react"],
    "plugins": [
        "hound-trace" // 添加该插件
    ]
}

注意:因为该插件会在函数中注入代码,建议只在开发环境下使用。

安装 hound-trace-ui

hound-trace-ui 提供了收集调用栈信息,以及可视化(使用的 mermaid )展示调用栈的接口。

安装:

yarn hound-trace-ui -D  # npm install hound-trace-ui -D

使用

首先需要导入包:

import houndTrace from "hound-trace-ui";

然后在你需要开始捕获调用栈的地方调用下面的函数:

houndTrace.start();

最后在你想要结束捕获的地方调用下面的函数:

houndTrace.end();

如果没有什么意外,会在页面上显示当前调用栈的流程图。

案例

这是 example 的代码经过 hound-trace 捕获后得到的图。

b.png

🤝 参与

欢迎反馈问题或建议!
点击这个链接提交 issues page.

造这个轮子的背景文章:写一个 JS 调用栈可视化工具 hound-trace


This README was generated with ❤️ by readme-md-generator

hound-trace's People

Contributors

cj0x39e avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.