Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

process-warning

Package Overview
Dependencies
Maintainers
7
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

process-warning - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

test/issue-88.test.js

44

index.js

@@ -46,5 +46,29 @@ 'use strict'

const emitted = new Map()
const opts = Object.create(null)
/**
* @typedef {number} STATE_CONSTANT
*/
/**
* @private
* @typdef {object} EMISSION_STATES
* @property {STATE_CONSTANT} UNLIMITED_INITIAL Indicates that the warning
* is to be issued an unlimited number of times but has not yet been
* emitted.
* @property {STATE_CONSTANT} UNLIMITED_ONGOING Indicates that the warning
* is to be issued an unlimited number of times and has been emitted at least
* once.
* @property {STATE_CONSTANT} LIMITED_INITIAL Indicates that the warning
* is to be issued only once but has not yet been emitted.
* @property {STATE_CONSTANT} LIMITED_FINAL Indicates that the warning
* is to be issued only once and has already been emitted.
*/
const STATES = {
UNLIMITED_INITIAL: 0,
UNLIMITED_ONGOING: -1,
LIMITED_INITIAL: 1,
LIMITED_FINAL: 2
}
/**
* Builds a new {@link ProcessWarning} and adds it to the

@@ -95,4 +119,3 @@ * {@link ProcessWarningManager} such that it can be emitted through the

Object.assign(opts, { unlimited })
emitted.set(code, unlimited)
emitted.set(code, unlimited ? STATES.UNLIMITED_INITIAL : STATES.LIMITED_INITIAL)
codes[code] = buildWarnOpts

@@ -142,5 +165,9 @@

function emit (code, a, b, c) {
if (emitted.get(code) === true && opts.unlimited === false) return
const state = emitted.get(code)
if (state === STATES.LIMITED_FINAL) return
if (codes[code] === undefined) throw new Error(`The code '${code}' does not exist`)
emitted.set(code, true)
emitted.set(
code,
state <= STATES.UNLIMITED_INITIAL ? STATES.UNLIMITED_ONGOING : STATES.LIMITED_FINAL
)

@@ -155,3 +182,8 @@ const warning = codes[code](a, b, c)

emit,
emitted
emitted: {
get (code) {
const state = emitted.get(code)
return state === STATES.UNLIMITED_ONGOING || state === STATES.LIMITED_FINAL
}
}
}

@@ -158,0 +190,0 @@ }

3

package.json
{
"name": "process-warning",
"version": "2.3.0",
"version": "2.3.1",
"description": "A small utility for creating warnings and emitting them.",

@@ -11,2 +11,3 @@ "main": "index.js",

"lint:fix": "standard --fix",
"benchmark": "node benchmarks/warn.js",
"test": "npm run test:unit && npm run test:jest && npm run test:typescript",

@@ -13,0 +14,0 @@ "test:jest": "jest jest.test.js",

'use strict'
const test = require('tap').test
const { test } = require('tap')
const build = require('..')

@@ -5,0 +5,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc