{"id":13447822,"url":"https://github.com/alexreardon/tiny-warning","last_synced_at":"2025-05-16T04:03:35.687Z","repository":{"id":46938367,"uuid":"151210228","full_name":"alexreardon/tiny-warning","owner":"alexreardon","description":"A tiny warning function","archived":false,"fork":false,"pushed_at":"2023-07-12T13:54:47.000Z","size":985,"stargazers_count":186,"open_issues_count":18,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-14T02:11:43.357Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexreardon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-02T06:31:57.000Z","updated_at":"2025-05-05T08:27:55.000Z","dependencies_parsed_at":"2024-06-18T12:29:50.420Z","dependency_job_id":"1892fc51-a065-4608-b16b-6834d29d0569","html_url":"https://github.com/alexreardon/tiny-warning","commit_stats":{"total_commits":27,"total_committers":7,"mean_commits":3.857142857142857,"dds":"0.37037037037037035","last_synced_commit":"aaf964ea1003630f7b102e1bdceb5bc7a76748d3"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexreardon%2Ftiny-warning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexreardon%2Ftiny-warning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexreardon%2Ftiny-warning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexreardon%2Ftiny-warning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexreardon","download_url":"https://codeload.github.com/alexreardon/tiny-warning/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464891,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:27.717Z","updated_at":"2025-05-16T04:03:35.664Z","avatar_url":"https://github.com/alexreardon.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# tiny-warning 🔬⚠️\n\n[![Build Status](https://travis-ci.org/alexreardon/tiny-warning.svg?branch=master)](https://travis-ci.org/alexreardon/tiny-warning)\n[![npm](https://img.shields.io/npm/v/tiny-warning.svg)](https://www.npmjs.com/package/tiny-warning) [![Downloads per month](https://img.shields.io/npm/dm/tiny-warning.svg)](https://www.npmjs.com/package/tiny-warning) [![dependencies](https://david-dm.org/alexreardon/tiny-warning.svg)](https://david-dm.org/alexreardon/tiny-warning)\n[![min](https://img.shields.io/bundlephobia/min/tiny-warning.svg)](https://www.npmjs.com/package/tiny-warning)\n[![minzip](https://img.shields.io/bundlephobia/minzip/tiny-warning.svg)](https://www.npmjs.com/package/tiny-warning)\n\nA tiny [`warning`](https://www.npmjs.com/package/warning) alternative.\n\n```js\nimport warning from 'tiny-warning';\n\nwarning(truthyValue, 'This should not log a warning');\n\nwarning(falsyValue, 'This should log a warning');\n// console.warn('Warning: This should log a warning');\n```\n\n## API: `(condition: mixed, message: string) =\u003e void`\n\n- `condition` is required and can be anything\n- `message` is a required string that will be passed onto `console.warn`\n\n## Why `tiny-warning`?\n\nThe [`library: warning`](https://www.npmjs.com/package/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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/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?')`\n\n## Dropping your `warning` for kb savings!\n\nWe recommend using [`babel-plugin-dev-expression`](https://www.npmjs.com/package/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.\n\nWhat it does it turn your code that looks like this:\n\n```js\nwarning(condition, 'My cool message that takes up a lot of kbs');\n```\n\nInto this\n\n```js\nif ('production' !== process.env.NODE_ENV) {\n  warning(condition, 'My cool message that takes up a lot of kbs');\n}\n```\n\nYour bundler can then drop the code in the `\"production\" !== process.env.NODE_ENV` block for your production builds\n\nFinal result:\n\n```js\n// nothing to see here! 👍\n```\n\n\u003e For `rollup` use [rollup-plugin-replace](https://github.com/rollup/rollup-plugin-replace) and set `NODE_ENV` to `production` and then `rollup` will treeshake out the unused code\n\u003e\n\u003e [`Webpack` instructions](https://webpack.js.org/guides/production/#specify-the-mode)\n\n## Builds\n\n- We have a `es` (EcmaScript module) build (because you _know_ you want to deduplicate this super heavy library)\n- We have a `cjs` (CommonJS) build\n- We have a `umd` (Universal module definition) build in case you needed it\n\nWe expect `process.env.NODE_ENV` to be available at module compilation. We cache this value\n\n## That's it!\n\n🤘\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexreardon%2Ftiny-warning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexreardon%2Ftiny-warning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexreardon%2Ftiny-warning/lists"}