{"_id":"process-warning","_rev":"202377","name":"process-warning","description":"A small utility for creating warnings and emitting them.","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"matteo.collina","email":""}],"time":{"modified":"2023-03-21T06:28:08.000Z","created":"2021-12-28T14:00:11.396Z","2.1.0":"2022-12-04T23:41:57.917Z","2.0.0":"2022-05-19T09:01:22.895Z","1.0.0":"2021-12-28T14:00:11.396Z"},"users":{},"author":{"name":"Tomas Della Vedova"},"repository":{"type":"git","url":"git+https://github.com/fastify/process-warning.git"},"versions":{"2.1.0":{"name":"process-warning","version":"2.1.0","description":"A small utility for creating warnings and emitting them.","main":"index.js","types":"types/index.d.ts","scripts":{"lint":"standard","test":"npm run test:unit && npm run test:jest && npm run test:typescript","test:jest":"jest jest.test.js","test:unit":"tap","test:typescript":"tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/process-warning.git"},"keywords":["fastify","error","warning","utility","plugin","emit","once"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/fastify/fastify-warning/issues"},"homepage":"https://github.com/fastify/fastify-warning#readme","devDependencies":{"benchmark":"^2.1.4","jest":"^29.0.1","standard":"^17.0.0","tap":"^16.3.0","tsd":"^0.24.1"},"gitHead":"f605697033b57a890b2702e6fd2dc866b41ca91e","_id":"process-warning@2.1.0","_nodeVersion":"16.17.0","_npmVersion":"9.1.2","dist":{"shasum":"1e60e3bfe8183033bbc1e702c2da74f099422d1a","size":4410,"noattachment":false,"key":"/process-warning/-/process-warning-2.1.0.tgz","tarball":"http://name.csiicloud.com:7001/process-warning/download/process-warning-2.1.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/process-warning_2.1.0_1670197317769_0.34160910183554405"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-12-04T23:42:01.260Z","publish_time":1670197317917,"_cnpm_publish_time":1670197317917},"2.0.0":{"name":"process-warning","version":"2.0.0","description":"A small utility for creating warnings and emitting them.","main":"index.js","types":"index.d.ts","scripts":{"test":"standard && ava -v test.js && jest jest.test.js && tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/process-warning.git"},"keywords":["fastify","error","warning","utility","plugin","emit","once"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/fastify/fastify-warning/issues"},"homepage":"https://github.com/fastify/fastify-warning#readme","devDependencies":{"ava":"^3.10.1","jest":"^27.0.1","standard":"^17.0.0","tsd":"^0.20.0"},"gitHead":"992426675464d4165478d8a080770db5e263e51b","_id":"process-warning@2.0.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"shasum":"341dbeaac985b90a04ebcd844d50097c7737b2ee","size":3973,"noattachment":false,"key":"/process-warning/-/process-warning-2.0.0.tgz","tarball":"http://name.csiicloud.com:7001/process-warning/download/process-warning-2.0.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/process-warning_2.0.0_1652950882799_0.5668469576371313"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-19T11:31:17.882Z","publish_time":1652950882895,"_cnpm_publish_time":1652950882895},"1.0.0":{"name":"process-warning","version":"1.0.0","description":"A small utility for creating warnings and emitting them.","main":"index.js","types":"index.d.ts","scripts":{"test":"standard && ava -v test.js && jest jest.test.js && tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/processs-warning.git"},"keywords":["fastify","error","warning","utility","plugin","emit","once"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/fastify/fastify-warning/issues"},"homepage":"https://github.com/fastify/fastify-warning#readme","devDependencies":{"ava":"^3.10.1","jest":"^27.0.1","standard":"^16.0.3","tsd":"^0.19.0"},"gitHead":"57eb5f271f7f1b5c05743fdfbffe96ae40458caf","_id":"process-warning@1.0.0","_nodeVersion":"12.21.0","_npmVersion":"6.14.11","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"980a0b25dc38cd6034181be4b7726d89066b4616","size":4299,"noattachment":false,"key":"/process-warning/-/process-warning-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/process-warning/download/process-warning-1.0.0.tgz"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/process-warning_1.0.0_1640700011252_0.06338313721771249"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-28T14:00:19.961Z","publish_time":1640700011396,"_cnpm_publish_time":1640700011396}},"readme":"# process-warning\n\n![CI](https://github.com/fastify/process-warning/workflows/CI/badge.svg)\n[![NPM version](https://img.shields.io/npm/v/process-warning.svg?style=flat)](https://www.npmjs.com/package/process-warning)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)\n\nA small utility for generating consistent warning objects across your codebase.\nIt also exposes a utility for emitting those warnings, guaranteeing that they are issued only once.\n\nThis module is used by the [Fastify](https://fastify.io) framework and it was called `fastify-warning` prior to version 1.0.0.\n\n### Install\n\n```\nnpm i process-warning\n```\n\n### Usage\n\nThe module exports a builder function that returns a utility for creating warnings and emitting them.\n\n```js\nconst warning = require('process-warning')()\n```\n\n#### Methods\n\n```\nwarning.create(name, code, message)\n```\n\n- `name` (`string`, required) - The error name, you can access it later with `error.name`. For consistency, we recommend prefixing module error names with `{YourModule}Warning`\n- `code` (`string`, required) - The warning code, you can access it later with `error.code`. For consistency, we recommend prefixing plugin error codes with `{ThreeLetterModuleName}_`, e.g. `FST_`. NOTE: codes should be all uppercase.\n- `message` (`string`, required) - The warning message. You can also use interpolated strings for formatting the message.\n\nThe utility also contains an `emit` function that you can use for emitting the warnings you have previously created by passing their respective code. A warning is guaranteed to be emitted only once.\n\n```\nwarning.emit(code [, a [, b [, c]]])\n```\n\n- `code` (`string`, required) - The warning code you intend to emit.\n- `[, a [, b [, c]]]` (`any`, optional) - Parameters for string interpolation.\n\n```js\nconst warning = require('process-warning')()\nwarning.create('FastifyWarning', 'FST_ERROR_CODE', 'message')\nwarning.emit('FST_ERROR_CODE')\n```\n\nHow to use an interpolated string:\n```js\nconst warning = require('process-warning')()\nwarning.create('FastifyWarning', 'FST_ERROR_CODE', 'Hello %s')\nwarning.emit('FST_ERROR_CODE', 'world')\n```\n\nThe module also exports an `warning.emitted` [Map](https://developer.mozilla.org/it/docs/Web/JavaScript/Reference/Global_Objects/Map), which contains all the warnings already emitted. Useful for testing.\n```js\nconst warning = require('process-warning')()\nwarning.create('FastifyWarning', 'FST_ERROR_CODE', 'Hello %s')\nconsole.log(warning.emitted.get('FST_ERROR_CODE')) // false\nwarning.emit('FST_ERROR_CODE', 'world')\nconsole.log(warning.emitted.get('FST_ERROR_CODE')) // true\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","_attachments":{},"homepage":"https://github.com/fastify/fastify-warning#readme","bugs":{"url":"https://github.com/fastify/fastify-warning/issues"},"license":"MIT"}