8.10.135 • Published 1 year ago

@womorg/computing-machine v8.10.135

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@womorg/computing-machine

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 @womorg/computing-machine

Usage

The module exports two builder functions for creating warnings.

const {
  createWarning,
  createDeprecation
} = require('@womorg/computing-machine')

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('@womorg/computing-machine')
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('@womorg/computing-machine')
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('@womorg/computing-machine')
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('@womorg/computing-machine')
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.

jasminetranspilerregexpECMAScript 2021xtermmimelogredacterror-handlinges2017StreamsarrayssanitizehookformsuperstructprivateHyBicall-bindremoveajves2018busyvarreact animationspecpromisesuser-streamsworkspace:*chromeharmonyvalidatorconcurrencypopmotionparserreadbatchstarterguidslicebabel-corerecursivepositivegenericsmergereduceparentsdependenciescallbindcryptostyled-componentsBigUint64Arrayelectronawaitsetterelboffsetcommand-lineURLSearchParamsbrowserdeepcopyvisualdragObject.assignterminaltermchromiumnested cssmulti-packagejwttrimEndWebSocketestree-0class-validatorcodescss variableposenamesencryptionhttpstypanioncssuninstallstableschemeframersharedarraybufferlengthfulldescriptorsmake dirisfindLastIndexInt32Array[[Prototype]]es-shim APIcolumnthrottleindicatorexpresstrimtoobjectlibphonenumberreal-timel10nstringagentES2016TypeScriptlintlistenershandlersreact-hook-formCSSStyleDeclarationsanitizationtrimStartmakefast-clonees6Object.valuesInt16Arrayfunctionalanimationdeepweakmapcss nestingtoArrayhasOwnmodulestestingjestRxphonetspureschemaURLArray.prototype.containsprocesspnpm9monorepofile systemloadbalancingrateconcatMapassertpostcssprotocol-buffersAsyncIteratorspringArray.prototype.flattenpromiseeventsmetadatapasswordmatches256shimassertsObjectsearchzodshebangconcatnumberwhatwgmiddlewarepreserve-symlinksglobworkermatchtypeTypeBoxInt8ArraysideasyncquerygetPrototypeOfextendfindLastIteratorwatchMapjapanesefastsameValueZeroYAMLregular expressionseventDispatcheroperating-systembalancedqueuedomnegative zeroconfigurablecryptstructuredCloneES2020autoscalingpropertylazynodejsrangeerrorcloudformation@@toStringTagObject.entriescloudfrontreadableregularfindupfpscharacterwidthnativewafargvsigintboundimmershellpropduplexmkdirspackagetyped arrayUint32Arrayquerystringchinesesignalspushshaminstallernope$.extendObject.keyswgetttykeyssyntaxES2018rmdirfast-deep-copyinconsoleeslint-pluginenderecmascriptsnstypeofzerostoragegatewaytslibconfigbrowserslisttypesafetoolstakesimpledbunicodepluginvaluereact posebabelobjectform-validationbundlingFunction.prototype.namedatastructuremapreduceflatreduxisConcatSpreadableFloat64ArrayhasOwnPropertyclassnamessymlinknpmcensorconstoptiondirtypedrequestformsMicrosoftES8es5invariantcomputed-typeslook6to5tostringtagansiinterruptsutilitylinewrapsqsjsiamfileinternalless cssincludesJSON-Schemaarktypedebugpackage.jsontesterfixed-widthroute53parselockfilestreamslesscssiterateflatMapjsonpathObservablesiterationstyleguideserializecode pointsmkdirpfind-upwhichUnderscore3deslinttexttimejsdiffeventEmitterbootstrap lessdatacompile lesslinklook-upsymbolbootstrap csscore-jses2016definePropertyvariables in css
@womorg/architecto-hic-sunt@womorg/deleniti-nostrum-et@womorg/deleniti-velit-voluptas@womorg/est-suscipit-quisquam@womorg/et-magni-consequatur@womorg/iure-quasi-reprehenderit@womorg/ipsum-quos-similique@womorg/quod-odit-assumenda@womorg/est-quis-quae@womorg/labore-tempora-recusandae@womorg/laborum-voluptates-molestias@womorg/porro-laboriosam-quod@womorg/repudiandae-maiores-quis@womorg/adipisci-enim-illum@womorg/aspernatur-quisquam-ipsam@womorg/dolor-accusamus-fugit@womorg/fugiat-animi-libero@womorg/harum-fugiat-illo@womorg/hic-deserunt-voluptas@womorg/neque-eum-quia@womorg/occaecati-a-iusto@womorg/nostrum-nulla-laboriosam@womorg/porro-impedit-suscipit@womorg/perferendis-unde-impedit@womorg/recusandae-eveniet-quos@womorg/dolorum-harum-explicabo@womorg/doloribus-quasi-in@womorg/illo-ea-maxime@womorg/illo-earum-eveniet@womorg/mollitia-quaerat-repellat@womorg/necessitatibus-cupiditate-fugit@womorg/neque-earum-aspernatur@womorg/quibusdam-tenetur-ratione@womorg/reiciendis-eum-voluptatum@womorg/accusantium-commodi-officia@womorg/accusantium-doloribus-quod@womorg/blanditiis-ipsum-maxime@womorg/consequuntur-consequatur-accusamus@womorg/cum-dolorem-corrupti@womorg/eos-blanditiis-excepturi@womorg/enim-nisi-vero@womorg/illum-aut-ut@womorg/ipsam-sint-eaque@womorg/omnis-laborum-asperiores@womorg/occaecati-ducimus-laboriosam@womorg/optio-quia-vero@womorg/saepe-enim-dolor@womorg/adipisci-maxime-facilis@womorg/aperiam-ullam-accusamus@womorg/blanditiis-fugiat-reprehenderit@womorg/aut-laboriosam-accusantium@womorg/autem-tempora-rem@womorg/ducimus-officia-voluptatum@womorg/ea-laborum-magnam@womorg/eum-nesciunt-quas@womorg/fantastic-giggle@womorg/excepturi-dolorem-illum@womorg/exercitationem-atque-voluptatem@womorg/literate-octo@womorg/quasi-eius-optio@womorg/quidem-assumenda-amet@womorg/quis-doloribus-maxime@womorg/repudiandae-dolorum-unde@womorg/sed-nihil-quos@womorg/similique-illo-dolorem@womorg/totam-expedita-quas@womorg/vitae-tenetur-pariatur@womorg/voluptatem-voluptatibus-illum@womorg/voluptates-vero-occaecati@womorg/totam-commodi-ratione@womorg/temporibus-corporis-omnis@womorg/tempora-maxime-voluptates@womorg/totam-eum-ipsum@womorg/ullam-perspiciatis-excepturi@womorg/studiou@womorg/ut-dolorem-corrupti@womorg/ut-qui-iste
8.9.130

1 year ago

8.9.127

1 year ago

8.9.126

1 year ago

8.9.125

1 year ago

8.9.124

1 year ago

8.9.129

1 year ago

8.9.128

1 year ago

8.9.123

1 year ago

8.9.122

1 year ago

8.9.121

1 year ago

8.9.120

1 year ago

8.9.119

1 year ago

8.9.118

1 year ago

8.9.117

1 year ago

8.10.133

1 year ago

8.10.134

1 year ago

8.10.135

1 year ago

8.10.130

1 year ago

8.10.131

1 year ago

8.10.132

1 year ago

8.8.115

1 year ago

8.8.114

1 year ago

8.8.117

1 year ago

8.8.116

1 year ago

8.8.111

1 year ago

8.8.110

1 year ago

8.8.113

1 year ago

8.8.112

1 year ago

8.8.108

1 year ago

8.8.107

1 year ago

8.8.109

1 year ago

8.8.104

1 year ago

8.8.103

1 year ago

8.8.106

1 year ago

8.8.105

1 year ago

8.8.99

1 year ago

8.8.100

1 year ago

8.8.102

1 year ago

8.8.101

1 year ago

8.8.97

1 year ago

8.8.98

1 year ago

8.8.96

1 year ago

7.8.93

1 year ago

7.8.96

1 year ago

7.8.95

1 year ago

7.8.94

1 year ago

7.8.89

1 year ago

7.8.92

1 year ago

7.8.91

1 year ago

7.8.90

1 year ago

7.8.86

1 year ago

7.8.85

1 year ago

7.8.88

1 year ago

7.8.87

1 year ago

7.8.82

1 year ago

7.8.84

1 year ago

7.8.83

1 year ago

7.8.79

1 year ago

7.8.81

1 year ago

7.8.80

1 year ago

7.8.78

1 year ago

7.8.77

1 year ago

7.8.76

1 year ago

7.7.76

1 year ago

5.7.61

1 year ago

4.7.59

1 year ago

7.7.63

1 year ago

7.7.67

1 year ago

7.7.66

1 year ago

7.7.65

1 year ago

7.7.64

1 year ago

7.7.69

1 year ago

6.7.61

1 year ago

7.7.68

1 year ago

6.7.62

1 year ago

6.7.63

1 year ago

7.7.70

1 year ago

7.7.74

1 year ago

7.7.73

1 year ago

7.7.72

1 year ago

7.7.71

1 year ago

4.5.50

1 year ago

4.5.51

1 year ago

7.7.75

1 year ago

4.5.54

1 year ago

4.4.43

1 year ago

4.5.55

1 year ago

4.5.52

1 year ago

4.5.53

1 year ago

4.4.46

1 year ago

4.5.56

1 year ago

4.4.45

1 year ago

4.5.57

1 year ago

4.4.44

1 year ago

4.7.60

1 year ago

4.7.61

1 year ago

4.6.59

1 year ago

4.5.47

1 year ago

4.5.48

1 year ago

4.6.57

1 year ago

4.6.58

1 year ago

4.5.46

1 year ago

4.5.49

1 year ago

4.4.42

1 year ago

3.4.40

1 year ago

3.4.41

1 year ago

3.4.42

1 year ago

3.4.39

1 year ago

3.4.36

1 year ago

3.4.37

1 year ago

3.4.38

1 year ago

3.2.26

1 year ago

3.4.29

1 year ago

3.2.28

1 year ago

3.2.27

1 year ago

3.3.28

1 year ago

3.3.29

1 year ago

3.4.30

1 year ago

3.4.31

1 year ago

3.4.32

1 year ago

3.4.33

1 year ago

3.4.34

1 year ago

3.4.35

1 year ago

3.2.24

1 year ago

3.2.25

1 year ago

3.2.23

1 year ago

3.2.20

1 year ago

3.2.22

1 year ago

3.2.21

1 year ago

3.2.19

1 year ago

3.2.18

1 year ago

3.2.17

1 year ago

3.2.16

1 year ago

3.2.15

1 year ago

3.2.14

1 year ago

3.2.13

1 year ago

3.2.12

1 year ago

3.1.12

1 year ago

3.1.11

1 year ago

3.1.10

1 year ago

3.1.9

1 year ago

3.1.7

1 year ago

3.1.8

1 year ago

3.1.6

1 year ago

3.1.5

1 year ago

2.1.5

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago