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

depurar

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

depurar

Debug with added sugar

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by380%
Maintainers
1
Weekly downloads
 
Created
Source

depurar

Build Status Coverage Status npm Dependency Status Development Dependency Status

depurar (first-person singular present indicative depuro, past participle depurado)

  1. to purify, cleanse
    2 (computing) To debug

Depurar is a wrapper around debug adding a couple of features for the truly lazy.

Install

npm install --save depurar

Added features

Automatically establish namespace

debug has the convention of prefixing debug output with a namespace in the form of: Library:feature. This allows us to quickly enable/disable debug output for some libraries or features. In my interpretation of this convention this often leads to ModuleName:ClassName.

So I got a bit tired of opening ~/code/foo/lib/Bar.coffee and typing:

debug = require("debug")("foo:Bar")
class Bar
  constructor: ->
    debug "ohai"

With Depurar, the second part will be based on the basename of the file where you require it:

debug = require("depurar")("foo")
# Sets the namespace to `foo:Bar` in the case of `~/code/foo/lib/Bar.coffee`

What's more, if you are really truly lazy, the first part of this namespace can even be guessed based on the directory name of your library/app, and

debug = require("depurar")()
# Sets the namespace to `foo:Bar` in the case of `~/code/foo/lib/Bar.coffee`

Pick color based on namespace, not rotation

debug by default picks the next color from a list, every time it gets instantiated. That's nice so you get a new color for every entity that's talking to you. However in async land this also often means that with every run or change, every entity has a new color again. First world's problems but the brain is great at recognizing patterns via color and so if every entity had it's own color, debug information would be easier to digest.

That's the reasoning. And that's why Depurar reduces namespaces to a color index via crc. This does not warrant unique colors across the board, but it does make every class or feature, always speak in the same color.

FAQ

Is Depurar more efficient than debug?

While I'm too lazy to benchmark, considering there's extra pathfinding and computation involved, I'd say: No. If your app's bottleneck is in requiring files, Depurar is not for you. That said, if the bottleneck in your app becomes Depurar, I'd either be very impressed or underwhelmed by your app.

Todo

  • Support for enabling adding the linenumber to the debug prefix
  • Support for disabling colorpicking by namespace
  • Handle & test the case where undefined is debugged

Sponsor Development

Like this project? Consider a donation.

Gittip donate button Flattr donate button PayPal donate button BitCoin donate button

Keywords

FAQs

Package last updated on 21 Jun 2015

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