Socket
Socket
Sign inDemoInstall

@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 8.3.3 to 9.0.0

2

dist/cached-fs.d.ts

@@ -1,2 +0,2 @@

import type { IFileSystem } from '@file-services/types';
import type { IFileSystem } from "@file-services/types";
export interface ICachedFileSystem extends IFileSystem {

@@ -3,0 +3,0 @@ /**

@@ -1,2 +0,2 @@

export * from './cached-fs';
export * from "./cached-fs";
//# sourceMappingURL=index.d.ts.map
{
"name": "@file-services/cached",
"description": "A file system wrapper that adds cache to any `IFileSystem` implementation.",
"version": "8.3.3",
"version": "9.0.0",
"main": "./dist/fs-cached.cjs",

@@ -21,4 +21,4 @@ "types": "./dist/index.d.ts",

"dependencies": {
"@file-services/types": "^8.3.3",
"@file-services/utils": "^8.3.3"
"@file-services/types": "^9.0.0",
"@file-services/utils": "^9.0.0"
},

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

@@ -19,15 +19,15 @@ # @file-services/cached

```ts
import { nodeFs } from '@file-services/node';
import { createCachedFs } from '@file-services/cached';
import { nodeFs } from "@file-services/node";
import { createCachedFs } from "@file-services/cached";
const cachedFs = createCachedFs(nodeFs);
cachedFs.writeFileSync('/file.js', 'CONTENT');
cachedFs.writeFileSync("/file.js", "CONTENT");
// calls fs
cachedFs.statSync('/file.js');
cachedFs.statSync("/file.js");
// cached
cachedFs.statSync('/file.js');
cachedFs.statSync("/file.js");
// clears the cache
cachedFs.invalidate('/file.js');
cachedFs.invalidate("/file.js");
```

@@ -34,0 +34,0 @@

@@ -1,3 +0,3 @@

import type { IFileSystem, IFileSystemStats, CallbackFnVoid } from '@file-services/types';
import { createFileSystem } from '@file-services/utils';
import type { IFileSystem, IFileSystemStats, CallbackFnVoid } from "@file-services/types";
import { createFileSystem } from "@file-services/utils";

@@ -20,3 +20,3 @@ const identity = (val: string) => val;

interface ISuccessCacheResult<T> {
kind: 'success';
kind: "success";
value: T;

@@ -26,3 +26,3 @@ }

interface IFailureCacheResult {
kind: 'failure';
kind: "failure";
error: Error;

@@ -38,4 +38,4 @@ }

const suffixTrue = delimiter + 'true';
const suffixFalse = delimiter + 'false';
const suffixTrue = delimiter + "true";
const suffixFalse = delimiter + "false";

@@ -99,3 +99,3 @@ const invalidateAbsolute = (absolutePath: string) => {

return fs.copyFile(sourcePath, destinationPath, ...args);
} as IFileSystem['copyFile'],
} as IFileSystem["copyFile"],
copyFileSync(sourcePath, destinationPath, ...args) {

@@ -110,3 +110,3 @@ destinationPath = fs.resolve(destinationPath);

return fs.mkdir(directoryPath, ...args);
} as IFileSystem['mkdir'],
} as IFileSystem["mkdir"],
mkdirSync(directoryPath, ...args) {

@@ -167,3 +167,3 @@ directoryPath = fs.resolve(directoryPath);

return fs.writeFile(filePath, ...args);
} as IFileSystem['writeFile'],
} as IFileSystem["writeFile"],
writeFileSync(filePath, ...args) {

@@ -182,3 +182,3 @@ if (filePath) {

if (cachedStats) {
if (cachedStats.kind === 'failure') {
if (cachedStats.kind === "failure") {
throw cachedStats.error;

@@ -190,6 +190,6 @@ }

const stats = fs.statSync(path, options);
statsCache.set(cacheKey, { kind: 'success', value: stats });
statsCache.set(cacheKey, { kind: "success", value: stats });
return stats as IFileSystemStats;
} catch (e) {
statsCache.set(cacheKey, { kind: 'failure', error: e as Error });
statsCache.set(cacheKey, { kind: "failure", error: e as Error });
throw e;

@@ -204,5 +204,5 @@ }

if (cachedStats) {
if (cachedStats.kind === 'failure') {
if (cachedStats.kind === "failure") {
(callback as (e: Error) => void)(cachedStats.error);
} else if (cachedStats.kind === 'success') {
} else if (cachedStats.kind === "success") {
callback(null, cachedStats.value as IFileSystemStats);

@@ -213,5 +213,5 @@ }

if (error) {
statsCache.set(cacheKey, { kind: 'failure', error });
statsCache.set(cacheKey, { kind: "failure", error });
} else {
statsCache.set(cacheKey, { kind: 'success', value: stats });
statsCache.set(cacheKey, { kind: "success", value: stats });
}

@@ -308,3 +308,3 @@

if (cachedStats) {
if (cachedStats.kind === 'failure') {
if (cachedStats.kind === "failure") {
throw cachedStats.error;

@@ -316,6 +316,6 @@ }

const stats = await promises.stat(path);
statsCache.set(cacheKey, { kind: 'success', value: stats });
statsCache.set(cacheKey, { kind: "success", value: stats });
return stats;
} catch (e) {
statsCache.set(cacheKey, { kind: 'failure', error: e as Error });
statsCache.set(cacheKey, { kind: "failure", error: e as Error });
throw e;

@@ -322,0 +322,0 @@ }

@@ -1,1 +0,1 @@

export * from './cached-fs';
export * from "./cached-fs";

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc