Git Product home page Git Product logo

warning's Introduction

Warning npm version

Greenkeeper badge A mirror of Facebook's Warning

Usage

npm install warning
// some script
var warning = require('warning');

var ShouldBeTrue = false;

warning(
  ShouldBeTrue,
  'This thing should be true but you set to false. No soup for you!'
);
//  'This thing should be true but you set to false. No soup for you!'

Similar to Facebook's (FB) invariant but only logs a warning if the condition is not met. This can be used to log issues in development environments in critical paths. Removing the logging code for production environments will keep the same logic and follow the same code paths.

FAQ (READ before opening an issue)

Why do you use console.error instead of console.warn ?

This is a mirror of Facebook's (FB) warning module used within React's source code (and other FB software). As such this module will mirror their code as much as possible.

The descision to use error over warn was made a long time ago by the FB team and isn't going to change anytime soon.

The source can be found here: https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/__forks__/warning.js The reasoning can be found here and elsewhere: facebook/fbjs#94 (comment)

Can I add X feature?

This is a mirror of Facebook's (FB) warning and as such the source and signature will mirror that module.

If you believe a feature is missing than please open a feature request there. If it is approved and merged in that this module will be updated to reflect that change, otherwise this module will not change.

Use in Production

It is recommended to add babel-plugin-dev-expression with this module to remove warning messages in production.
















Don't Forget To Be Awesome

warning's People

Contributors

berkeleytrue avatar ctumolosus avatar emeegeemee avatar greenkeeper[bot] avatar jedwards1211 avatar leipert avatar trysound avatar whtsky avatar zertosh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.