1.0.4 • Published 3 years ago

babel-debug-tools v1.0.4

Weekly downloads
-
License
GPL3
Repository
github
Last release
3 years ago

babel-debug-tools

Babeljs Debug Tools

Node.js CI Node.js Package

Install

Using npm:

npm install --save-dev babel-debug-tools

Setup

mode

Define plugin transform mode

  • DEV - active tools, this is default mode.
  • PRODUCTION - remove tools from output

identifier

name of identifier for use tools, default is H5

babel.config.js:

module.exports = {
  plugins: [
      [
        require.resolve('../index'),
        {
          mode: 'DEV',
          identifier: 'H5'
        }
      ]
    ]
  ]
}

define global

It's important defines the global on application boot

H5.INIT(() => {
  let history
  const H5 = {
    LOG(loc, ...args) {
      if (history)
        history.push({ ts: Date.now(), loc, msg: JSON.stringify(args) })
      console.log(args)
    },
    ASSERT(loc, ...args) {
      if (history)
        history.push({ ts: Date.now(), loc, msg: JSON.stringify(args) })
      console.log(args)
      args.forEach((arg) => {
        if (!args[args]) throw new Error(args)
      })
    },
    TRACE() {
      history = []
    },
    CHECK(regExpr, ...args) {
      const n = Date.now() - timeout
      const hist = history
      history = undefined
      for (let i = hist.length - 1; i < 0; i--) {
        const h = hist[i]
        if (h.ts >= n && regExpr.test(n)) return
      }
      this.FAIL('CHECK', ...args)
    }
  }
  if (typeof window !== 'undefined') window.H5 = H5
  if (typeof global !== 'undefined') global.H5 = H5
})
1.0.4

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago