Socket
Socket
Sign inDemoInstall

fdir

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fdir - npm Package Compare versions

Comparing version 6.3.0 to 6.4.0

1

dist/api/functions/join-path.d.ts
import { Options, PathSeparator } from "../../types";
export declare function joinPathWithBasePath(filename: string, directoryPath: string): string;
export declare function joinDirectoryPath(filename: string, directoryPath: string, separator: PathSeparator): string;
export type JoinPathFunction = (filename: string, directoryPath: string) => string;
export declare function build(root: string, options: Options): JoinPathFunction;

17

dist/api/functions/join-path.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.build = exports.joinDirectoryPath = void 0;
exports.build = exports.joinDirectoryPath = exports.joinPathWithBasePath = void 0;
const path_1 = require("path");
const utils_1 = require("../../utils");
function joinPathWithBasePath(filename, directoryPath) {
return directoryPath + filename;
}
function joinPathWithRelativePath(root) {
exports.joinPathWithBasePath = joinPathWithBasePath;
function joinPathWithRelativePath(root, options) {
return function (filename, directoryPath) {
return directoryPath.substring(root.length) + filename;
const sameRoot = directoryPath.startsWith(root);
if (sameRoot)
return directoryPath.replace(root, "") + filename;
else
return ((0, utils_1.convertSlashes)((0, path_1.relative)(root, directoryPath), options.pathSeparator) +
options.pathSeparator +
filename);
};

@@ -22,3 +31,3 @@ }

return relativePaths && root
? joinPathWithRelativePath(root)
? joinPathWithRelativePath(root, options)
: includeBasePath

@@ -25,0 +34,0 @@ ? joinPathWithBasePath

@@ -6,3 +6,3 @@ "use strict";

return function (directoryPath, paths) {
paths.push((directoryPath || ".").substring(root.length));
paths.push(directoryPath.substring(root.length) || ".");
};

@@ -12,3 +12,3 @@ }

return function (directoryPath, paths, filters) {
const relativePath = directoryPath.substring(root.length);
const relativePath = directoryPath.substring(root.length) || ".";
if (filters.every((filter) => filter(relativePath, true))) {

@@ -23,4 +23,5 @@ paths.push(relativePath);

const pushDirectoryFilter = (directoryPath, paths, filters) => {
if (filters.every((filter) => filter(directoryPath, true))) {
paths.push(directoryPath);
const path = directoryPath || ".";
if (filters.every((filter) => filter(path, true))) {
paths.push(path);
}

@@ -27,0 +28,0 @@ };

@@ -56,3 +56,3 @@ "use strict";

function build(options, isSynchronous) {
if (!options.resolveSymlinks)
if (!options.resolveSymlinks || options.excludeSymlinks)
return null;

@@ -59,0 +59,0 @@ if (options.useRealPaths)

@@ -17,4 +17,3 @@ import { ResultCallback, Options } from "../types";

start(): TOutput | null;
private normalizePath;
private walk;
}

@@ -62,3 +62,3 @@ "use strict";

};
this.root = this.normalizePath(root);
this.root = (0, utils_1.normalizePath)(root, this.state.options);
/*

@@ -81,17 +81,4 @@ * Perf: We conditionally change functions according to options. This gives a slight

}
normalizePath(path) {
const { resolvePaths, normalizePath, pathSeparator } = this.state.options;
const pathNeedsCleaning = (process.platform === "win32" && path.includes("/")) ||
path.startsWith(".");
if (resolvePaths)
path = (0, path_1.resolve)(path);
if (normalizePath || pathNeedsCleaning)
path = (0, utils_1.cleanPath)(path);
if (path === ".")
return "";
const needsSeperator = path[path.length - 1] !== pathSeparator;
return (0, utils_1.convertSlashes)(needsSeperator ? path + pathSeparator : path, pathSeparator);
}
walk = (entries, directoryPath, depth) => {
const { paths, options: { filters, resolveSymlinks, exclude, maxFiles, signal }, } = this.state;
const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, }, } = this.state;
if ((signal && signal.aborted) || (maxFiles && paths.length > maxFiles))

@@ -103,3 +90,4 @@ return;

const entry = entries[i];
if (entry.isFile() || (entry.isSymbolicLink() && !resolveSymlinks)) {
if (entry.isFile() ||
(entry.isSymbolicLink() && !resolveSymlinks && !excludeSymlinks)) {
const filename = this.joinPath(entry.name, directoryPath);

@@ -114,7 +102,7 @@ this.pushFile(filename, files, this.state.counts, filters);

}
else if (entry.isSymbolicLink() && resolveSymlinks) {
let path = this.joinPath(entry.name, directoryPath);
else if (entry.isSymbolicLink() && this.resolveSymlink) {
let path = joinPath.joinPathWithBasePath(entry.name, directoryPath);
this.resolveSymlink(path, this.state, (stat, resolvedPath) => {
if (stat.isDirectory()) {
resolvedPath = this.normalizePath(resolvedPath);
resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options);
if (exclude && exclude(entry.name, resolvedPath))

@@ -125,2 +113,5 @@ return;

else {
const filename = (0, path_1.basename)(resolvedPath);
const directoryPath = (0, utils_1.normalizePath)((0, path_1.dirname)(resolvedPath), this.state.options);
resolvedPath = this.joinPath(filename, directoryPath);
this.pushFile(resolvedPath, files, this.state.counts, filters);

@@ -127,0 +118,0 @@ }

/// <reference types="node" />
import { Output, OnlyCountsOutput, GroupOutput, PathsOutput, Options, FilterPredicate, ExcludePredicate } from "../types";
import { Output, OnlyCountsOutput, GroupOutput, PathsOutput, Options, FilterPredicate, ExcludePredicate, GlobParams } from "../types";
import { APIBuilder } from "./api-builder";
import type { PicomatchOptions } from "picomatch";
export declare class Builder<TReturnType extends Output = PathsOutput> {
import type picomatch from "picomatch";
export declare class Builder<TReturnType extends Output = PathsOutput, TGlobFunction = typeof picomatch> {
private readonly globCache;
private options;
constructor(options?: Partial<Options>);
group(): Builder<GroupOutput>;
private globFunction?;
constructor(options?: Partial<Options<TGlobFunction>>);
group(): Builder<GroupOutput, TGlobFunction>;
withPathSeparator(separator: "/" | "\\"): this;

@@ -26,4 +27,5 @@ withBasePath(): this;

exclude(predicate: ExcludePredicate): this;
onlyCounts(): Builder<OnlyCountsOutput>;
crawl(root: string): APIBuilder<TReturnType>;
onlyCounts(): Builder<OnlyCountsOutput, TGlobFunction>;
crawl(root?: string): APIBuilder<TReturnType>;
withGlobFunction<TFunc>(fn: TFunc): Builder<TReturnType, TFunc>;
/**

@@ -36,5 +38,6 @@ * @deprecated Pass options using the constructor instead:

*/
crawlWithOptions(root: string, options: Partial<Options>): APIBuilder<TReturnType>;
glob(...patterns: string[]): this;
globWithOptions(patterns: string[], options: PicomatchOptions): this;
crawlWithOptions(root: string, options: Partial<Options<TGlobFunction>>): APIBuilder<TReturnType>;
glob(...patterns: string[]): Builder<TReturnType, TGlobFunction>;
globWithOptions(patterns: string[]): Builder<TReturnType, TGlobFunction>;
globWithOptions(patterns: string[], ...options: GlobParams<TGlobFunction>): Builder<TReturnType, TGlobFunction>;
}

@@ -23,4 +23,6 @@ "use strict";

};
globFunction;
constructor(options) {
this.options = { ...this.options, ...options };
this.globFunction = this.options.globFunction;
}

@@ -97,2 +99,7 @@ group() {

}
withGlobFunction(fn) {
// cast this since we don't have the new type params yet
this.globFunction = fn;
return this;
}
/**

@@ -111,12 +118,16 @@ * @deprecated Pass options using the constructor instead:

glob(...patterns) {
return this.globWithOptions(patterns, { dot: true });
if (this.globFunction) {
return this.globWithOptions(patterns);
}
return this.globWithOptions(patterns, ...[{ dot: true }]);
}
globWithOptions(patterns, options) {
globWithOptions(patterns, ...options) {
const globFn = (this.globFunction || pm);
/* c8 ignore next 5 */
if (!pm) {
throw new Error(`Please install picomatch: "npm i picomatch" to use glob matching.`);
if (!globFn) {
throw new Error('Please specify a glob function to use glob matching.');
}
var isMatch = this.globCache[patterns.join("\0")];
if (!isMatch) {
isMatch = pm(patterns, options);
isMatch = globFn(patterns, ...options);
this.globCache[patterns.join("\0")] = isMatch;

@@ -123,0 +134,0 @@ }

@@ -34,3 +34,3 @@ /// <reference types="node" />

export type PathSeparator = "/" | "\\";
export type Options = {
export type Options<TGlobFunction = unknown> = {
includeBasePath?: boolean;

@@ -49,2 +49,3 @@ includeDirs?: boolean;

excludeFiles?: boolean;
excludeSymlinks?: boolean;
exclude?: ExcludePredicate;

@@ -54,2 +55,6 @@ relativePaths?: boolean;

signal?: AbortSignal;
globFunction?: TGlobFunction;
};
export type GlobMatcher = (test: string) => boolean;
export type GlobFunction = ((glob: string | string[], ...params: unknown[]) => GlobMatcher);
export type GlobParams<T> = T extends (globs: string | string[], ...params: infer TParams extends unknown[]) => GlobMatcher ? TParams : [];
import { PathSeparator } from "./types";
export declare function cleanPath(path: string): string;
export declare function convertSlashes(path: string, separator: PathSeparator): string;
export declare function normalizePath(path: string, options: {
resolvePaths?: boolean;
normalizePath?: boolean;
pathSeparator: PathSeparator;
}): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertSlashes = exports.cleanPath = void 0;
exports.normalizePath = exports.convertSlashes = exports.cleanPath = void 0;
const path_1 = require("path");

@@ -19,1 +19,15 @@ function cleanPath(path) {

exports.convertSlashes = convertSlashes;
function normalizePath(path, options) {
const { resolvePaths, normalizePath, pathSeparator } = options;
const pathNeedsCleaning = (process.platform === "win32" && path.includes("/")) ||
path.startsWith(".");
if (resolvePaths)
path = (0, path_1.resolve)(path);
if (normalizePath || pathNeedsCleaning)
path = cleanPath(path);
if (path === ".")
return "";
const needsSeperator = path[path.length - 1] !== pathSeparator;
return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
}
exports.normalizePath = normalizePath;
{
"name": "fdir",
"version": "6.3.0",
"version": "6.4.0",
"description": "The fastest directory crawler & globbing alternative to glob, fast-glob, & tiny-glob. Crawls 1m files in < 1s",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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

<a href="https://www.npmjs.com/package/fdir"><img src="https://img.shields.io/npm/v/fdir?style=for-the-badge"/></a>
<a href="https://www.npmjs.com/package/fdir"><img src="https://img.shields.io/npm/dt/fdir?style=for-the-badge"/></a>
<a href="https://www.npmjs.com/package/fdir"><img src="https://img.shields.io/npm/dw/fdir?style=for-the-badge"/></a>
<a href="https://codeclimate.com/github/thecodrr/fdir/maintainability"><img src="https://img.shields.io/codeclimate/maintainability-percentage/thecodrr/fdir?style=for-the-badge"/></a>

@@ -30,6 +30,2 @@ <a href="https://coveralls.io/github/thecodrr/fdir?branch=master"><img src="https://img.shields.io/coveralls/github/thecodrr/fdir?style=for-the-badge"/></a>

## Support
> Do you like this project? **[Support me by donating](https://ko-fi.com/thecodrr)**, creating an issue, becoming a stargazer, or opening a pull request. Thanks.
## 🚄 Quickstart

@@ -82,16 +78,17 @@

1. [mdn/yari](https://github.com/mdn/yari)
2. [streetwriters/notesnook](https://github.com/streetwriters/notesnook)
3. [zhangdaren/miniprogram-to-uniapp](https://github.com/zhangdaren/miniprogram-to-uniapp)
4. [imba/imba](https://github.com/imba/imba)
5. [moroshko/react-scanner](https://github.com/moroshko/react-scanner)
6. [netlify/build](https://github.com/netlify/build)
7. [FredKSchott/snowpack](https://github.com/FredKSchott/snowpack)\*
8. [yassinedoghri/astro-i18next](https://github.com/yassinedoghri/astro-i18next)
9. [selfrefactor/rambda](https://github.com/selfrefactor/rambda)
1. [rollup/plugins](https://github.com/rollup/plugins)
2. [SuperchupuDev/tinyglobby](https://github.com/SuperchupuDev/tinyglobby)
3. [pulumi/pulumi](https://github.com/pulumi/pulumi)
4. [dotenvx/dotenvx](https://github.com/dotenvx/dotenvx)
5. [mdn/yari](https://github.com/mdn/yari)
6. [streetwriters/notesnook](https://github.com/streetwriters/notesnook)
7. [imba/imba](https://github.com/imba/imba)
8. [moroshko/react-scanner](https://github.com/moroshko/react-scanner)
9. [netlify/build](https://github.com/netlify/build)
10. [yassinedoghri/astro-i18next](https://github.com/yassinedoghri/astro-i18next)
11. [selfrefactor/rambda](https://github.com/selfrefactor/rambda)
12. [whyboris/Video-Hub-App](https://github.com/whyboris/Video-Hub-App)
- `snowpack` has since been discontinued.
## 🦮 LICENSE
Copyright &copy; 2023 Abdullah Atta under MIT. [Read full text here.](https://github.com/thecodrr/fdir/raw/master/LICENSE)
Copyright &copy; 2024 Abdullah Atta under MIT. [Read full text here.](https://github.com/thecodrr/fdir/raw/master/LICENSE)
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