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

@file-services/cached

Package Overview
Dependencies
Maintainers
4
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@file-services/cached - npm Package Compare versions

Comparing version 7.0.1 to 7.2.0

41

dist/cached-fs.js

@@ -11,2 +11,3 @@ "use strict";

const realpathCache = new Map();
const realpathNativeCache = new Map();
const { promises, delimiter } = fs;

@@ -18,2 +19,3 @@ const suffixTrue = delimiter + 'true';

realpathCache.delete(cachePath);
realpathNativeCache.delete(cachePath);
statsCache.delete(cachePath + suffixTrue);

@@ -29,2 +31,7 @@ statsCache.delete(cachePath + suffixFalse);

}
for (const key of realpathNativeCache.keys()) {
if (key.startsWith(prefix)) {
realpathNativeCache.delete(key);
}
}
for (const key of statsCache.keys()) {

@@ -36,2 +43,24 @@ if (key.startsWith(prefix)) {

};
function realpathSync(path) {
path = fs.resolve(path);
const cacheKey = getCanonicalPath(path);
const cachedActualPath = realpathCache.get(cacheKey);
if (cachedActualPath !== undefined) {
return cachedActualPath;
}
const actualPath = fs.realpathSync(path);
realpathCache.set(cacheKey, actualPath);
return actualPath;
}
realpathSync.native = function realpathSyncNative(path) {
path = fs.resolve(path);
const cacheKey = getCanonicalPath(path);
const cachedActualPath = realpathNativeCache.get(cacheKey);
if (cachedActualPath !== undefined) {
return cachedActualPath;
}
const actualPath = fs.realpathSync.native(path);
realpathNativeCache.set(cacheKey, actualPath);
return actualPath;
};
return {

@@ -165,13 +194,3 @@ ...(0, utils_1.createFileSystem)({

},
realpathSync(path) {
path = fs.resolve(path);
const cacheKey = getCanonicalPath(path);
const cachedActualPath = realpathCache.get(cacheKey);
if (cachedActualPath !== undefined) {
return cachedActualPath;
}
const actualPath = fs.realpathSync(path);
realpathCache.set(cacheKey, actualPath);
return actualPath;
},
realpathSync,
realpath(path, callback) {

@@ -178,0 +197,0 @@ path = fs.resolve(path);

{
"name": "@file-services/cached",
"description": "A file system wrapper that adds cache to any `IFileSystem` implementation.",
"version": "7.0.1",
"version": "7.2.0",
"main": "dist/index.js",

@@ -12,4 +12,4 @@ "scripts": {

"dependencies": {
"@file-services/types": "^7.0.1",
"@file-services/utils": "^7.0.1"
"@file-services/types": "^7.2.0",
"@file-services/utils": "^7.2.0"
},

@@ -16,0 +16,0 @@ "files": [

@@ -33,2 +33,3 @@ import type { IFileSystem, IFileSystemStats, CallbackFnVoid } from '@file-services/types';

const realpathCache = new Map<string, string>();
const realpathNativeCache = new Map<string, string>();
const { promises, delimiter } = fs;

@@ -42,2 +43,3 @@

realpathCache.delete(cachePath);
realpathNativeCache.delete(cachePath);
statsCache.delete(cachePath + suffixTrue);

@@ -53,2 +55,7 @@ statsCache.delete(cachePath + suffixFalse);

}
for (const key of realpathNativeCache.keys()) {
if (key.startsWith(prefix)) {
realpathNativeCache.delete(key);
}
}
for (const key of statsCache.keys()) {

@@ -61,2 +68,26 @@ if (key.startsWith(prefix)) {

function realpathSync(path: string): string {
path = fs.resolve(path);
const cacheKey = getCanonicalPath(path);
const cachedActualPath = realpathCache.get(cacheKey);
if (cachedActualPath !== undefined) {
return cachedActualPath;
}
const actualPath = fs.realpathSync(path);
realpathCache.set(cacheKey, actualPath);
return actualPath;
}
realpathSync.native = function realpathSyncNative(path: string): string {
path = fs.resolve(path);
const cacheKey = getCanonicalPath(path);
const cachedActualPath = realpathNativeCache.get(cacheKey);
if (cachedActualPath !== undefined) {
return cachedActualPath;
}
const actualPath = fs.realpathSync.native(path);
realpathNativeCache.set(cacheKey, actualPath);
return actualPath;
};
return {

@@ -186,13 +217,3 @@ ...createFileSystem({

},
realpathSync(path) {
path = fs.resolve(path);
const cacheKey = getCanonicalPath(path);
const cachedActualPath = realpathCache.get(cacheKey);
if (cachedActualPath !== undefined) {
return cachedActualPath;
}
const actualPath = fs.realpathSync(path);
realpathCache.set(cacheKey, actualPath);
return actualPath;
},
realpathSync,
realpath(path, callback) {

@@ -199,0 +220,0 @@ path = fs.resolve(path);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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