Socket
Socket
Sign inDemoInstall

nock

Package Overview
Dependencies
Maintainers
4
Versions
430
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nock - npm Package Compare versions

Comparing version 14.0.0-beta.9 to 14.0.0-beta.10

27

lib/common.js

@@ -521,11 +521,18 @@ 'use strict'

const timeouts = []
const intervals = []
const immediates = []
const timeouts = new Set()
const immediates = new Set()
const wrapTimer =
(timer, ids) =>
(...args) => {
const id = timer(...args)
ids.push(id)
(callback, ...timerArgs) => {
const cb = (...callbackArgs) => {
try {
// eslint-disable-next-line n/no-callback-literal
callback(...callbackArgs)
} finally {
ids.delete(id)
}
}
const id = timer(cb, ...timerArgs)
ids.add(id)
return id

@@ -535,9 +542,7 @@ }

const setTimeout = wrapTimer(timers.setTimeout, timeouts)
const setInterval = wrapTimer(timers.setInterval, intervals)
const setImmediate = wrapTimer(timers.setImmediate, immediates)
function clearTimer(clear, ids) {
while (ids.length) {
clear(ids.shift())
}
ids.forEach(clear)
ids.clear()
}

@@ -548,3 +553,2 @@

clearTimer(clearTimeout, timeouts)
clearTimer(clearInterval, intervals)
clearTimer(clearImmediate, immediates)

@@ -717,3 +721,2 @@ }

setImmediate,
setInterval,
setTimeout,

@@ -720,0 +723,0 @@ stringifyRequest,

@@ -14,3 +14,2 @@ 'use strict'

const { BatchInterceptor } = require('@mswjs/interceptors')
const { FetchInterceptor } = require('@mswjs/interceptors/fetch')
const {

@@ -24,3 +23,3 @@ default: nodeInterceptors,

name: 'nock-interceptor',
interceptors: [...nodeInterceptors, new FetchInterceptor()],
interceptors: nodeInterceptors,
})

@@ -405,10 +404,2 @@ let isNockActive = false

nockRequest.on('response', nockResponse => {
// TODO: Consider put empty headers object as default when create the ClientRequest
if (nockResponse.req.headers) {
// forward Nock request headers to the MSW request
Object.entries(nockResponse.req.headers).map(([k, v]) =>
mswRequest.headers.set(k, v),
)
}
const response = createResponse(nockResponse)

@@ -415,0 +406,0 @@ controller.respondWith(response)

@@ -10,3 +10,2 @@ 'use strict'

const { BatchInterceptor } = require('@mswjs/interceptors')
const { FetchInterceptor } = require('@mswjs/interceptors/fetch')
const {

@@ -24,3 +23,3 @@ default: nodeInterceptors,

name: 'nock-interceptor',
interceptors: [...nodeInterceptors, new FetchInterceptor()],
interceptors: nodeInterceptors,
})

@@ -27,0 +26,0 @@

@@ -10,3 +10,3 @@ {

],
"version": "14.0.0-beta.9",
"version": "14.0.0-beta.10",
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",

@@ -26,3 +26,3 @@ "repository": {

"dependencies": {
"@mswjs/interceptors": "^0.33.2",
"@mswjs/interceptors": "^0.34.0",
"json-stringify-safe": "^5.0.1",

@@ -29,0 +29,0 @@ "propagate": "^2.0.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