{"_id":"fastify-warning","_rev":"9-dd14fdbbebdc4cbc912ca5238b4a46f0","name":"fastify-warning","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"fastify-warning","version":"0.1.0","keywords":["fastify","error","warning","utility","plugin","emit","once"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","_id":"fastify-warning@0.1.0","maintainers":[{"name":"delvedor","email":"tommydelved@gmail.com"}],"homepage":"https://github.com/fastify/fastify-warning#readme","bugs":{"url":"https://github.com/fastify/fastify-warning/issues"},"dist":{"shasum":"319846d6d481cc90ed5d9caf828df82515e3ad30","tarball":"https://registry.npmjs.org/fastify-warning/-/fastify-warning-0.1.0.tgz","fileCount":8,"integrity":"sha512-it+4HwH11RMqjQF5EbDavVXpemm6kMwDM0p3WMJXN1pJJ7RRHmVws5UaYUCItXcZQnxf838Q/aiFhVXPNjiO4g==","signatures":[{"sig":"MEUCIQDgVqOej1pDMldq/FTKtq3kcavEqjoa0k43tiViVSH4IwIgf8ILKJqUxXve0DKcCT3tot+iOFLmpssXZ0I+4nayH1U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11092,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfHYQZCRA9TVsSAnZWagAA0YkP/3v0M6l78F7ydPxnxpnY\nv1Gzjhmqpkuv634E72y8G7usTIcXDPn5UdAVYUabFKFqPrNog5qGoMSo4REd\nein5q8B2YQsPMaolmQS1JaWO4g0yt8ACaEGTaJ0F3Gl7jHv4W1yct5npt7Yb\nPd7YsfVJ+QbH6WuJwT3YZeiUzuGCuD6Gaa9H2wQUtgb1BpVQl/vR4n6t4XKJ\ngJCMH/11L+hVmCkEEi+4Zrq9EKt0Rn0Ae4Wi2WcHf6RUpJoVQIrNLPdeKYEb\nAfibdL80oud054xdzmAhc1qOMEjIm/HXoc1wGLZ0JENJ7/VG93EW27a7dDUU\nW9pRbGUrK/i25wBUgczIwNxkXjXWCZMbvMDP5fZZ+Uu6hjCFY8kzrlXTPCT1\nNurUyGFhJ3wvt11dAog+YaunLp5oanYwR4aRgI7LKEC5xFc5xPeCenuANacy\na3qwuY4WrZ8XLz8ZjIg8C0tXFyYussaabqh8WDPsj9lT+kmwlAOFvmOW3sr6\nvXIJh585BSXhzgQHPIaHk+EDAwJhCW6iYbFAgqDDC+6rqaDd0WBLZZHcrhxj\ngFF7ALvoFJZfS9hI0mK6qWwKI/JdTJPfUbvYFWiBQ//P1mXyODPODWn/FQDB\ncdNOT0RWCbmXC1xzT8yEo34Y713zf9JXhnTtrxsKTW5jadkLP9KZ3ET7I84a\ntm00\r\n=pISe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","types":"index.d.ts","gitHead":"d3647c1cb8bdf302e143756a065376ad7fea42ef","scripts":{"test":"standard && ava -v && tsd"},"_npmUser":{"name":"delvedor","email":"tommydelved@gmail.com"},"deprecated":"This module renamed to process-warning","repository":{"url":"git+https://github.com/fastify/fastify-warning.git","type":"git"},"_npmVersion":"6.14.5","description":"A small utility for creating warnings and emitting them.","directories":{},"_nodeVersion":"12.18.1","_hasShrinkwrap":false,"devDependencies":{"ava":"^3.10.1","tsd":"^0.13.1","standard":"^14.3.4"},"_npmOperationalInternal":{"tmp":"tmp/fastify-warning_0.1.0_1595769881250_0.4278316151227577","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"fastify-warning","version":"0.2.0","keywords":["fastify","error","warning","utility","plugin","emit","once"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","_id":"fastify-warning@0.2.0","maintainers":[{"name":"delvedor","email":"tommydelved@gmail.com"}],"homepage":"https://github.com/fastify/fastify-warning#readme","bugs":{"url":"https://github.com/fastify/fastify-warning/issues"},"dist":{"shasum":"e717776026a4493dc9a2befa44db6d17f618008f","tarball":"https://registry.npmjs.org/fastify-warning/-/fastify-warning-0.2.0.tgz","fileCount":9,"integrity":"sha512-s1EQguBw/9qtc1p/WTY4eq9WMRIACkj+HTcOIK1in4MV5aFaQC9ZCIt0dJ7pr5bIf4lPpHvAtP2ywpTNgs7hqw==","signatures":[{"sig":"MEUCIQDYVV92OKbOH1Z0SCndcgAPOJc6Eh2Hu3c9HmLIlUueQQIgCJmTaqAn/pL7qCegVSwX9U8bmHiMhXm+hEbR33RCGyo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10980,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfID4zCRA9TVsSAnZWagAAjrcP/jPEdql8Jlm6Dzl89Swm\nN2/0YPgYcGleIZ26WwulIIcHhLv1WcDiHXo4gPEgSiYTZxAuUMs3ocbNc/8e\nXTCCOPfmdLQkvFY/iJYvUJE41hdmNHwCHeQcCd1MFP2A3jS9RzVZR+xNynne\n+zzwMFn3wcLWg0vEDphPuEZSvlKFOrByADsLc2A/5iUgDwA5r98GEoc7fK9B\nUnk3Eelrs/p7pNV/aqcqOyRF6O3a8SvtGjdRytvlOm+ISxgCgFjOmaoxHxMe\nXzcVn7WdkIpuNKtnt30o9Dxm4kLE6GU8SnbHQORaSOWIv+Xkk35YidoLUFUj\nBF0IjD58n2ntihN8JAZBOo3eqE+TY1JojMfx5Z4QLjtjVogAmQFu3SBiH3Nx\nlo+eEICVHrYNa09ZdcjCP4wn7OWOJLWSX3/AMdmgb2MeM/W0wybKwBdJBAV7\nAljeKtrLlx8CiVufsbjGqXOJAZj8YndUmIvneRe4g1oVDrzZOMRPp0afiBRx\n59K5PEERL/qba/actU2XDAURDIk/FzzASNESjgYsM0zvSnubcX8ONPp/TeBp\nrjGFoRlz8c2YbBuDW4eqRjFnEF2/loiTdAwSzDt26lVSlADydqlxHLEZPg/D\n3oZzZkXzBpeCyRHiZ7Yf5lou3EHIwbaPKQNQ5zrjJ+fhw4NbWi9b8dh90vFJ\nOFJn\r\n=nsGt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","types":"index.d.ts","gitHead":"bbbae97ce990657a7089bb71b425937e96b9b2e7","scripts":{"test":"standard && ava -v test.js && jest jest.test.js && tsd"},"_npmUser":{"name":"delvedor","email":"tommydelved@gmail.com"},"deprecated":"This module renamed to process-warning","repository":{"url":"git+https://github.com/fastify/fastify-warning.git","type":"git"},"_npmVersion":"6.14.5","description":"A small utility for creating warnings and emitting them.","directories":{},"_nodeVersion":"12.18.1","_hasShrinkwrap":false,"devDependencies":{"ava":"^3.10.1","tsd":"^0.13.1","jest":"^26.1.0","standard":"^14.3.4"},"_npmOperationalInternal":{"tmp":"tmp/fastify-warning_0.2.0_1595948594364_0.8030099287583465","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-07-26T13:24:41.250Z","modified":"2026-08-02T09:46:07.094Z","0.1.0":"2020-07-26T13:24:41.371Z","0.2.0":"2020-07-28T15:03:14.497Z"},"bugs":{"url":"https://github.com/fastify/fastify-warning/issues"},"author":{"name":"Tomas Della Vedova"},"license":"MIT","homepage":"https://github.com/fastify/fastify-warning#readme","keywords":["fastify","error","warning","utility","plugin","emit","once"],"repository":{"url":"git+https://github.com/fastify/fastify-warning.git","type":"git"},"description":"A small utility for creating warnings and emitting them.","maintainers":[{"email":"tommydelved@gmail.com","name":"delvedor"}],"readme":"# fastify-warning\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)  ![build](https://github.com/fastify/fastify-warning/workflows/build/badge.svg)\n\nA small utility, used by Fastify itself, for generating consistent warning objects across your codebase and plugins.\nIt also exposes a utility for emitting those warnings, guaranteeing that they are issued only once.\n\n### Install\n```\nnpm i fastify-warning\n```\n\n### Usage\n\nThe module exports a builder function that returns an utility for creating warnings and emitting them.\n\n```js\nconst warning = require('fastify-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 to prefix plugin error names with `FastifWarning{YourPluginName}`\n- `code` (`string`, required) - The warning code, you can access it later with `error.code`. For consistency, we recommend to prefix plugin error codes with `FST_{YourPluginName}_`\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('fastify-warning')()\nwarning.create('FastifyWarning', 'FST_ERROR_CODE', 'message')\nwarning.emit('FST_ERROR_CODE')\n```\n\nHow to use a interpolated string:\n```js\nconst warning = require('fastify-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('fastify-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","readmeFilename":"README.md"}