6.3.73 • Published 11 months ago

@hishprorg/veniam-dolore v6.3.73

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@hishprorg/veniam-dolore

CI NPM version js-standard-style

A small utility for generating consistent warning objects across your codebase. It also exposes a utility for emitting those warnings, guaranteeing that they are issued only once (unless configured otherwise).

This module is used by the Fastify framework and it was called fastify-warning prior to version 1.0.0.

Install

npm i @hishprorg/veniam-dolore

Usage

The module exports two builder functions for creating warnings.

const {
  createWarning,
  createDeprecation
} = require('@hishprorg/veniam-dolore')

const warning = createWarning({
  name: 'ExampleWarning',
  code: 'EXP_WRN_001',
  message: 'Hello %s',
  unlimited: true
})
warning('world')

Methods

createWarning({ name, code, message[, unlimited] })
  • 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
  • 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.
  • message (string, required) - The warning message. You can also use interpolated strings for formatting the message.
  • options (object, optional) - Optional options with the following properties:
    • unlimited (boolean, optional) - Should the warning be emitted more than once? Defaults to false.
createDeprecation({code, message[, options]})

This is a wrapper for createWarning. It is equivalent to invoking createWarning with the name parameter set to "DeprecationWarning".

Deprecation warnings have extended support for the Node.js CLI options: --throw-deprecation, --no-deprecation, and --trace-deprecation.

warning([, a [, b [, c]]])

The returned warning function can used for emitting warnings. A warning is guaranteed to be emitted at least once.

  • [, a [, b [, c]]] (any, optional) - Parameters for string interpolation.
const { createWarning } = require('@hishprorg/veniam-dolore')
const FST_ERROR_CODE = createWarning({ name: 'MyAppWarning', code: 'FST_ERROR_CODE', message: 'message' })
FST_ERROR_CODE()

How to use an interpolated string:

const { createWarning } = require('@hishprorg/veniam-dolore')
const FST_ERROR_CODE = createWarning({ name: 'MyAppWarning', code: 'FST_ERROR_CODE', message: 'Hello %s'})
FST_ERROR_CODE('world')

The warning object has methods and properties for managing the warning's state. Useful for testing.

const { createWarning } = require('@hishprorg/veniam-dolore')
const FST_ERROR_CODE = createWarning({ name: 'MyAppWarning', code: 'FST_ERROR_CODE', message: 'Hello %s'})
console.log(FST_ERROR_CODE.emitted) // false
FST_ERROR_CODE('world')
console.log(FST_ERROR_CODE.emitted) // true

const FST_ERROR_CODE_2 = createWarning('MyAppWarning', 'FST_ERROR_CODE_2', 'Hello %s')
FST_ERROR_CODE_2.emitted = true
FST_ERROR_CODE_2('world') // will not be emitted because it is not unlimited

How to use an unlimited warning:

const { createWarning } = require('@hishprorg/veniam-dolore')
const FST_ERROR_CODE = createWarning({ name: 'MyAppWarning', code: 'FST_ERROR_CODE', message: 'Hello %s', unlimited: true })
FST_ERROR_CODE('world') // will be emitted
FST_ERROR_CODE('world') // will be emitted again

Suppressing warnings

It is possible to suppress warnings by utilizing one of node's built-in warning suppression mechanisms.

Warnings can be suppressed:

  • by setting the NODE_NO_WARNINGS environment variable to 1
  • by passing the --no-warnings flag to the node process
  • by setting '--no-warnings' in the NODE_OPTIONS environment variable

For more information see node's documentation.

License

Licensed under MIT.

cryptoroutingviewECMAScript 2015nodepostcss-pluginmatchshamcallbackgetOwnPropertyDescriptorurlasyncdirectorySymbol.toStringTagUnderscorevalidatesameValueZerodeepcloneclass-validatorfunctiondeterministicvarkoreanrecursiveprivatejsonschemagetoptruntimeenderclassesObjectES2018json-schema-validatormixinsterminalcore-jsfastcopytrimStartwalktypefast-deep-copyasterisksaccessorES2015symlinkiterateschematermfastifyrandomES2023stringfsdeep-cloneECMAScript 3chinesedom-testing-libraryArray.prototype.findLaststylesreducertoolkitdependenciesconstworkerECMAScript 2018executeawspredictableoutputeslintmetadatasignalsyntaxtrimthreeMapinternalStreamsacornfpmergeprettyredactauthkeyoncedefinereact posetoSortedforkObject.getPrototypeOfespreeJSON-SchemaObject.definePropertyArrayBuffer#sliceimmutablespinnerhttpqueryregexpebsletspinnerslibphonenumbertakebyteArray.prototype.filteridentifiersshellidlestatussettingsflattenlintinpnpm9ES2017gesturesworkspace:*efficientsuperstructarrayflatMapfpsselfomitrapiddiffreact-testing-librarytypescriptmruECMAScriptimmerhookformdayjssometypesmodulejsdommake diriteratorprotocol-buffersqsfront-endpackage managerwaitcss-in-jscontainsmockendpointsideRxlastes5nested cssECMAScript 2023snsasciipostcsstrimEndes2015real-timebootstrap lessresolvedomnpmES2019css lessyupjoiserverwaapiECMAScript 2022ECMAScript 7BigUint64ArraycryptloadingstylesheetArrayBufferprotobufFloat32Arraystatelesssortarrayslocalprivate datauninstallmockingextraglobclientTypeScriptsetPrototypeOfqueueastpipeinvariantmakevariablesapollofigletexit-codelocationtyped-0esform-validationcolorTypedArrayemitboundargumentpathmacoschannellockfilegradients css3call-boundObject.entriesregular expressionfunction.lengthtypeerrorvarseast-asian-widthclassnamechilddependency managerhardlinksinputargsES2021curriedio-tsgdprES7jshintautoscalingjson-schemaSymbolieRegExp.prototype.flagsURLSearchParamsfindLastIndexstringifierawesomesaucebinariesstreamsintrinsiccallcopyTypeBoxes2017Pushgenericsfast-deep-cloneminimaldefinePropertypatchtacitfluxcolourgroupESargvbcryptECMAScript 2016getbrowserlist.envReactiveExtensionstostringtagequalityObject.assignoperating-systemobjjson6to5findLastjsdiffproxyexecfileiampusherrorInt16ArrayserializertypeofRFC-6455slicevaluecolumnsfilecompile lesslesscssconfigES3Object.isconcatiszodimportcensorjsxkeysdragcloudformationbootstrap cssgetintrinsicjwtrdsInt32ArrayagentUint8Arraytyped arrayconsumeextendfastclonefindstyleguidebindIteratorpyyamlutilitiesregularSystem.globalESnextsuperagent.gitignoreRxJSzxString.prototype.trimclassnameslesscurlObject.valuesestreedata3dES8symbolsvariables in cssStreampinosignedgitignorecollection.es6testeroffsetfast-cloneairbnbarktypeMicrosofteventDispatchercheckbyteOffsetyamldataviewes8timeUint32ArrayregexreduxvalidationspringassertECMAScript 2020filtercodesnamesloggereffect-tstoStringTagsymlinkstrimLeftcss nestingelectronconfigurablecertificatesfnmatchsigintwritableFunction.prototype.namehasOwnPropertyoptimistframerutilityenvironmentsArray.prototype.flattenoptimizer_.extendsetfull-widthqueueMicrotasknodejsclonebannergetPrototypeOfglobalThisquotewhicharraybuffercollectionflatwhatwgreusehandlercallbindequalwgetgroupByformatassignreact animationdateshebangphonereplaydescriptorsttyAsyncIteratortypesafebabel-coreArrayRegExp#flagsECMAScript 2017assertionglobalsrobusthas-ownelasticachereadwarningflagsECMAScript 2021browserindicatorback-endInt8ArraysequencemovecharactervaluesReflect.getPrototypeOftoobjectcommanderexecpackageslivedeepcopystructuredClone
6.3.73

11 months ago

6.3.72

11 months ago

6.3.71

11 months ago

6.3.70

11 months ago

5.3.70

11 months ago

5.3.69

11 months ago

5.3.68

11 months ago

5.3.67

11 months ago

5.3.66

11 months ago

5.3.65

11 months ago

5.3.64

11 months ago

5.2.64

11 months ago

5.2.63

11 months ago

5.2.62

11 months ago

5.2.61

11 months ago

5.2.60

11 months ago

5.2.59

12 months ago

5.2.58

12 months ago

5.2.57

12 months ago

5.2.56

12 months ago

5.2.55

12 months ago

5.2.54

12 months ago

5.2.53

12 months ago

5.2.52

12 months ago

5.2.51

12 months ago

5.2.50

12 months ago

5.2.49

12 months ago

5.2.48

12 months ago

5.2.47

12 months ago

5.2.46

12 months ago

5.2.45

12 months ago

5.2.44

12 months ago

5.2.43

12 months ago

5.2.42

12 months ago

5.2.41

12 months ago

5.2.40

12 months ago

5.2.39

1 year ago

5.2.38

1 year ago

5.2.37

1 year ago

4.2.37

1 year ago

4.2.36

1 year ago

4.2.35

1 year ago

4.2.34

1 year ago

4.2.33

1 year ago

4.1.33

1 year ago

4.1.32

1 year ago

4.1.31

1 year ago

4.1.30

1 year ago

3.1.30

1 year ago

3.1.29

1 year ago

2.1.29

1 year ago

2.1.28

1 year ago

2.1.27

1 year ago

2.0.27

1 year ago

2.0.26

1 year ago

2.0.25

1 year ago

2.0.24

1 year ago

2.0.23

1 year ago

2.0.22

1 year ago

2.0.21

1 year ago

2.0.20

1 year ago

2.0.19

1 year ago

2.0.18

1 year ago

2.0.17

1 year ago

2.0.16

1 year ago

2.0.15

1 year ago

2.0.14

1 year ago

2.0.13

1 year ago

2.0.12

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago