Socket
Socket
Sign inDemoInstall

complain

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    complain

Mark methods as deprecated and warn the user when they're called


Version published
Maintainers
1
Install size
12.2 kB
Created

Readme

Source

complain

Mark methods as deprecated and warn the user when they're called. Forked from brianc/node-deprecate.

api

var complain = require('complain');

complain()

`complain([String message1 [, String message2 [,...]]], [Object options])`

Call complain within a function you are deprecating. It will spit out all the messages to the console the first time and only the first time the method is called.

1var complain = require('complain');
23var someDeprecatedFunction = function() {
4complain('someDeprecatedFunction() is deprecated');
5  │ };
6  │
…  │ // …
3031someDeprecatedFunction();

program output:

Options

location: a string in the format ${filepath}:${line}:${column} indicating where the deprecated function was called from. Setting this to false disables outputting the location and will only log the message once.

complain.method()

`complain.method(Object proto, String methodName, [String message1 [, String message2 [,...]]], [Object options])`

Deprecates a method on an object:

complain.method(console, 'log', 'You should not log.');

complain.fn()

`complain.fn(Function func, [String message1 [, String message2 [,...]]], [Object options])`

Deprecates a function and returns it:

console.log = complain.fn(console.log, 'You should not log.');

complain.color

Set to false to disable color output. Set to true to force color output. Defaults to the value of complain.stream.isTTY.

complain.colors

Controls the colors used when logging. Default value:

{
  warning: '\x1b[31;1m', // red, bold
  message: false, // use system color
  location: '\u001b[90m' // gray
}

How the default looks on a dark background vs. a light background:

complain.silence

When true, do nothing when the complain method is called.

complain.stream

The to which output is written. Defaults to process.stderr.

complain.log(message)

The function used to log, by default this function writes to complain.stream and falls back to console.warn.

You can replace this with your own logging method.

license

MIT

Keywords

FAQs

Last updated on 14 Dec 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc