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

ts-debug

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-debug

Configurable console wrapper for Typescript

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3K
increased by14.7%
Maintainers
1
Weekly downloads
 
Created
Source

Typescript Debugger

Console Wrappper

This tiny lib written in Typescript allows you to leave your debugging logs inside your project without worries of removing them for production environment.

Installation

npm install --save ts-debug

Usage

Debugger's instance has the exactly same methods as standard console. Its constructor takes 3 parameters:

  • console: Console - object implementing Console interface, e.g. console or its wrapper
  • isEnabled: boolean = true - determines if Debugger should be enabled (you shoud pass here false to prevent displaying console output in production environment)
  • prefix: string = '' - specifies prefix for console outputs, e.g. "[DEBUG] "
Example:
import { Debugger } from 'ts-debug';
const Config = { isProd: false }; // example config in your application

const debug = new Debugger(console, !Config.isProd, '[DEBUG] ');
debug.log('Debugger is enabled!');
debug.warn('An error occured while processing: ', { example: 'object' });

You can see real-life usage of this lib in ngx-store.

Additional methods

  • throw(error: Error) - throws usual (sync) error in debug mode and non-blocking (async) otherwise

Compatibility

For TypeScript 3+ use v1.3+ For older versions use v1.2

Keywords

FAQs

Package last updated on 28 Nov 2018

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