Gathering detailed insights and metrics for tiny-warning
Gathering detailed insights and metrics for tiny-warning
Gathering detailed insights and metrics for tiny-warning
Gathering detailed insights and metrics for tiny-warning
npm install tiny-warning
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
182 Stars
30 Commits
17 Forks
4 Watching
15 Branches
5 Contributors
Updated on 08 Oct 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-1.7%
1,458,806
Compared to previous day
Last week
4.6%
7,586,518
Compared to previous week
Last month
10.7%
31,450,827
Compared to previous month
Last year
-8.1%
367,606,327
Compared to previous year
A tiny warning
alternative.
1import warning from 'tiny-warning'; 2 3warning(truthyValue, 'This should not log a warning'); 4 5warning(falsyValue, 'This should log a warning'); 6// console.warn('Warning: This should log a warning');
(condition: mixed, message: string) => void
condition
is required and can be anythingmessage
is a required string that will be passed onto console.warn
tiny-warning
?The library: warning
supports passing in arguments to the warning
function in a sprintf style (condition, format, a, b, c, d, e, f)
. It has internal logic to execute the sprintf substitutions. tiny-warning
has dropped all of the sprintf logic. tiny-warning
allows you to pass a single string message. With template literals there is really no need for a custom message formatter to be built into the library. If you need a multi part message you can just do this: warning(condition, 'Hello, ${name} - how are you today?')
warning
for kb savings!We recommend using babel-plugin-dev-expression
to remove warning
calls from your production build. This saves you kb's as well as avoids logging warnings to the console for production.
What it does it turn your code that looks like this:
1warning(condition, 'My cool message that takes up a lot of kbs');
Into this
1if ('production' !== process.env.NODE_ENV) { 2 warning(condition, 'My cool message that takes up a lot of kbs'); 3}
Your bundler can then drop the code in the "production" !== process.env.NODE_ENV
block for your production builds
Final result:
1// nothing to see here! 👍
For
rollup
use rollup-plugin-replace and setNODE_ENV
toproduction
and thenrollup
will treeshake out the unused code
es
(EcmaScript module) build (because you know you want to deduplicate this super heavy library)cjs
(CommonJS) buildumd
(Universal module definition) build in case you needed itWe expect process.env.NODE_ENV
to be available at module compilation. We cache this value
🤘
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 7/27 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
55 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More