Socket
Socket
Sign inDemoInstall

@jsenv/filesystem

Package Overview
Dependencies
Maintainers
2
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/filesystem - npm Package Compare versions

Comparing version 4.0.10 to 4.1.0

2

package.json
{
"name": "@jsenv/filesystem",
"version": "4.0.10",
"version": "4.1.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -5,2 +5,21 @@ export const guardTooFastSecondCall = (

) => {
let previousCallMs
return (...args) => {
const nowMs = Date.now()
if (previousCallMs) {
const msEllapsed = nowMs - previousCallMs
if (msEllapsed < cooldownBetweenFileEvents) {
previousCallMs = null
return
}
}
previousCallMs = nowMs
callback(...args)
}
}
export const guardTooFastSecondCallPerFile = (
callback,
cooldownBetweenFileEvents = 40,
) => {
const previousCallMsMap = new Map()

@@ -7,0 +26,0 @@ return (fileEvent) => {

@@ -7,3 +7,3 @@ import { readdirSync, statSync } from "node:fs"

import { statsToType } from "./internal/statsToType.js"
import { guardTooFastSecondCall } from "./internal/guard_second_call.js"
import { guardTooFastSecondCallPerFile } from "./internal/guard_second_call.js"
import { createWatcher } from "./internal/createWatcher.js"

@@ -53,9 +53,15 @@ import { trackRessources } from "./internal/trackRessources.js"

if (added) {
added = guardTooFastSecondCall(added, cooldownBetweenFileEvents)
added = guardTooFastSecondCallPerFile(added, cooldownBetweenFileEvents)
}
if (updated) {
updated = guardTooFastSecondCall(updated, cooldownBetweenFileEvents)
updated = guardTooFastSecondCallPerFile(
updated,
cooldownBetweenFileEvents,
)
}
if (removed) {
removed = guardTooFastSecondCall(removed, cooldownBetweenFileEvents)
removed = guardTooFastSecondCallPerFile(
removed,
cooldownBetweenFileEvents,
)
}

@@ -62,0 +68,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