New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

complete-file-system-cache

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

complete-file-system-cache - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

33

dist/complete-file-system-cache.cjs.js
'use strict';
var node_path = require('node:path');
var node_url = require('node:url');
var node_fs = require('node:fs');
const COMPLETE_FILES_SYSTEM_CACHE_FOLDER_NAME = '.complete-file-system-cache';
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('complete-file-system-cache.cjs.js', document.baseURI).href)));
node_path.dirname(__filename$1);
class CompleteFileSystemCache {

@@ -51,11 +47,26 @@ projectRootDir;

search(includedPathSegments, excludedPathSegments = [], ignoreCase = true) {
const cb = (path) => includedPathSegments.some((includedPathSegment) => path.includes(includedPathSegment));
const ignoreCaseCb = (path) => includedPathSegments.some((includedPathSegment) => path.toLowerCase().includes(includedPathSegment.toLowerCase()));
return this.getCacheDirectoryItems()?.reduce((acc, path) => {
const filePaths = this.getCachedFilePaths(+path);
const cbForStringArray = (path) => includedPathSegments.every((includedPathSegment) => path.includes(includedPathSegment));
const ignoreCaseCbForStringArray = (path) => includedPathSegments.every((includedPathSegment) => path.toLowerCase().includes(includedPathSegment.toLowerCase()));
const cbForRegExp = (path) => includedPathSegments.test(path);
const ignoreCaseCbForRegExp = (path) => includedPathSegments.test(path.toLowerCase());
let cb;
if (ignoreCase) {
if (Array.isArray(includedPathSegments))
cb = ignoreCaseCbForStringArray;
else if (includedPathSegments instanceof RegExp)
cb = ignoreCaseCbForRegExp;
}
else {
if (Array.isArray(includedPathSegments))
cb = cbForStringArray;
else if (includedPathSegments instanceof RegExp)
cb = cbForRegExp;
}
return (this.getCacheDirectoryItems()?.reduce((acc, path) => {
const filePaths = this.getCachedFilePaths(path) || [];
acc.push(...filePaths
.filter((path) => !excludedPathSegments.some((excludedPathSegment) => path.includes(excludedPathSegment)))
.filter(ignoreCase ? ignoreCaseCb : cb));
.filter(cb));
return acc;
}, []);
}, []) || []);
}

@@ -69,3 +80,3 @@ getCacheDirectoryItems() {

readDirRecursively(path, filePaths = []) {
if (node_fs.lstatSync(path).isDirectory()) {
if (!node_path.extname(path)) {
try {

@@ -72,0 +83,0 @@ node_fs.readdirSync(path).forEach((directory) => this.readDirRecursively(node_path.join(path, directory), filePaths));

@@ -9,5 +9,5 @@ type FilePaths = string[];

reloadFileSystemCache(): void;
getCachedFilePaths(index: number): null | FilePaths;
getCachedFilePaths(index: string): null | FilePaths;
cleanCache(): void;
search(includedPathSegments: string[], excludedPathSegments?: string[], ignoreCase?: boolean): string[];
search(includedPathSegments: string[] | RegExp, excludedPathSegments?: string[], ignoreCase?: boolean): string[];
private getCacheDirectoryItems;

@@ -14,0 +14,0 @@ private readDirRecursively;

@@ -1,9 +0,5 @@

import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { existsSync, readdirSync, mkdirSync, writeFileSync, readFileSync, rmSync, lstatSync } from 'node:fs';
import { join, extname } from 'node:path';
import { existsSync, readdirSync, mkdirSync, writeFileSync, readFileSync, rmSync } from 'node:fs';
const COMPLETE_FILES_SYSTEM_CACHE_FOLDER_NAME = '.complete-file-system-cache';
const __filename = fileURLToPath(import.meta.url);
dirname(__filename);
class CompleteFileSystemCache {

@@ -49,11 +45,26 @@ projectRootDir;

search(includedPathSegments, excludedPathSegments = [], ignoreCase = true) {
const cb = (path) => includedPathSegments.some((includedPathSegment) => path.includes(includedPathSegment));
const ignoreCaseCb = (path) => includedPathSegments.some((includedPathSegment) => path.toLowerCase().includes(includedPathSegment.toLowerCase()));
return this.getCacheDirectoryItems()?.reduce((acc, path) => {
const filePaths = this.getCachedFilePaths(+path);
const cbForStringArray = (path) => includedPathSegments.every((includedPathSegment) => path.includes(includedPathSegment));
const ignoreCaseCbForStringArray = (path) => includedPathSegments.every((includedPathSegment) => path.toLowerCase().includes(includedPathSegment.toLowerCase()));
const cbForRegExp = (path) => includedPathSegments.test(path);
const ignoreCaseCbForRegExp = (path) => includedPathSegments.test(path.toLowerCase());
let cb;
if (ignoreCase) {
if (Array.isArray(includedPathSegments))
cb = ignoreCaseCbForStringArray;
else if (includedPathSegments instanceof RegExp)
cb = ignoreCaseCbForRegExp;
}
else {
if (Array.isArray(includedPathSegments))
cb = cbForStringArray;
else if (includedPathSegments instanceof RegExp)
cb = cbForRegExp;
}
return (this.getCacheDirectoryItems()?.reduce((acc, path) => {
const filePaths = this.getCachedFilePaths(path) || [];
acc.push(...filePaths
.filter((path) => !excludedPathSegments.some((excludedPathSegment) => path.includes(excludedPathSegment)))
.filter(ignoreCase ? ignoreCaseCb : cb));
.filter(cb));
return acc;
}, []);
}, []) || []);
}

@@ -67,3 +78,3 @@ getCacheDirectoryItems() {

readDirRecursively(path, filePaths = []) {
if (lstatSync(path).isDirectory()) {
if (!extname(path)) {
try {

@@ -70,0 +81,0 @@ readdirSync(path).forEach((directory) => this.readDirRecursively(join(path, directory), filePaths));

{
"name": "complete-file-system-cache",
"version": "1.3.3",
"version": "1.3.4",
"description": "This library can be used to sync a folder from your device to GitHub. This is a fun project and I do not recommend to push large files.",

@@ -5,0 +5,0 @@ "main": "dist/complete-file-system-cache.cjs.js",

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

## Complete File System Cache v1.3.0 Documentation
## Complete File System Cache v1.3.4 Documentation

@@ -3,0 +3,0 @@ <p align="center">

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