Code Monkey home page Code Monkey logo

unist-util-trace's Introduction

unist-util-trace

Chat

unist utility to trace changes while processing

Install

npm:

npm install unist-util-trace

Usage

Minimal usage

To achieve optimal usage, employ the () => syntax. Apply these tracepoints to the chain. Upon the initial call, only the tree is stored for comparison. Upon subsequent calls, it displays a diff relative to the previously saved unist tree.

.use(() => unistUtilTrace.diff()) // first call: save tree
//...
.use(() => unistUtilTrace.diff()) // second call: show diff
const { unistUtilTrace } = require("unist-util-trace")
const traceDiffSettings = {
  reporter: ["unist-diff"]
}
module.exports = {
  plugins: [
    ["remark-frontmatter", "yaml"],
    [
      "remark-retext",
      unified()
        .use(require("retext-english"))
        .use(require("retext-syntax-urls"))
        .use(() => unistUtilTrace.diff(traceDiffSettings))  // first to set tracepoint
        .use(require("retext-syntax-mentions"), { style: /^@[\w-]{1,40}$/ })
        .use(() => unistUtilTrace.diff(traceDiffSettings)) // second to see diffs from mentions
        .use(require("retext-emoji"))
        .use(() => unistUtilTrace.diff(traceDiffSettings)) // third to see diffs in retext-emoji

Reporter

available reporters:

const traceDiffSettings = {
  reporter: [ "unist-diff", 
              "diff-json", 
              "diff-inspect-full", 
              "diff-inspect-plain", 
              "json-diff-patch"
            ]
}

Reporter unist-diff

using unist-diff

Reporter diff-json

using diff.json

Reporter diff-inspect-full

using unist-util-inspect without options and then diff.diffLines

Reporter diff-inspect-plain

using unist-util-inspect with options for less noise and then diff.diffLines

Reporter json-diff-patch

using jsondiffpatch with the console formatter

Logger

Logger logDot

show a dot for each file

new line after 100 items

Logger logFileName

show current file name

  • newLine: false -> change current line
  • newLine: true -> each name on a new line

Logger logNodeInspect

log all nodeType nodes with inspect

Logger logTreeeInspect

run inspect on the current tree

API

Related

License

MIT © Michael Nietzold / Muescha

unist-util-trace's People

Contributors

dependabot[bot] avatar muescha avatar

Stargazers

 avatar

Watchers

 avatar  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.