Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-debug-tools

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-debug-tools

Helpers for debug Javascript Applications

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
Maintainers
1
Weekly downloads
 
Created
Source

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
})

Keywords

FAQs

Package last updated on 05 Nov 2020

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