warning
    Overview
    Documentation
    Tutorials
    Chat
    Insights
    Code
    Dependencies
    Contributors
    Jobs

warning

A mirror of Facebook's Warning

4.0.3  •  Updated 1 years ago  •  by Berkeley Martinez  •  MIT License

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: https://github.com/facebook/fbjs/pull/94#issuecomment-168332326

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

Popularity

Maintenance

Development

Last ver 1 year ago
Created 5 years ago
Last commit 1 year ago
21 days between commits

Technology

Node version: 10.15.0
9.5K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

10 contributors
Berkeley Martinez
Maintainer, 34 commits, 10 merges, 4 PRs
Berkeley Martinez
22 commits
Andres Suarez
5 commits, 2 PRs
Works at facebook
greenkeeper[bot]
2 commits
Lukas Eipert
1 commits, 1 PRs
Works at GitLab
Justin Emge
1 commits, 1 PRs

Tags

warning
facebook
react
invariant
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookTwitterLinkedIn
© 2020 Devstore, Inc.