🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@lxf2513/readdir-sync-recursive

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

@lxf2513/readdir-sync-recursive - npm Package Compare versions

Comparing version
1.2.2
to
1.3.0
+15
-15
dist/index.cjs

@@ -7,3 +7,3 @@ 'use strict';

function isDirectory(path) {
function isDir(path) {
try {

@@ -15,18 +15,18 @@ return node_fs.statSync(path).isDirectory();

}
function index(path, returnType) {
if (!isDirectory(path)) {
function index(path, type) {
if (!isDir(path)) {
return [];
}
const readdirResults = [];
function readdir(dirpath) {
const results = [];
function readdir(dir) {
try {
const readdirResult = node_fs.readdirSync(dirpath, { encoding: "utf-8" });
for (let i = 0; i < readdirResult.length; i++) {
const resultPath = node_path.join(dirpath, readdirResult[i]);
const relativeResultPath = node_path.relative(path, resultPath);
const absolutePath = node_path.join(node_process.cwd(), resultPath);
const pushPath = returnType === "relativePath" ? resultPath : returnType === "absolutePath" ? absolutePath : relativeResultPath;
readdirResults.push(pushPath);
if (isDirectory(resultPath)) {
readdir(resultPath);
const result = node_fs.readdirSync(dir, { encoding: "utf-8" });
for (let i = 0; i < result.length; i++) {
const rpath = node_path.join(dir, result[i]);
const rrpath = node_path.relative(path, rpath);
const apath = node_path.join(node_process.cwd(), rpath);
const ppath = type === "relativePath" ? rpath : type === "absolutePath" ? apath : rrpath;
results.push(ppath);
if (isDir(rpath)) {
readdir(rpath);
}

@@ -39,5 +39,5 @@ }

readdir(path);
return readdirResults;
return results;
}
module.exports = index;

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

declare function export_default(path: string, returnType?: 'absolutePath' | 'relativePath'): string[];
declare function export_default(path: string, type?: 'absolutePath' | 'relativePath'): string[];
export { export_default as default };
export = export_default;

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

declare function export_default(path: string, returnType?: 'absolutePath' | 'relativePath'): string[];
declare function export_default(path: string, type?: 'absolutePath' | 'relativePath'): string[];
export { export_default as default };

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

declare function export_default(path: string, returnType?: 'absolutePath' | 'relativePath'): string[];
declare function export_default(path: string, type?: 'absolutePath' | 'relativePath'): string[];
export { export_default as default };

@@ -5,3 +5,3 @@ import { statSync, readdirSync } from 'node:fs';

function isDirectory(path) {
function isDir(path) {
try {

@@ -13,18 +13,18 @@ return statSync(path).isDirectory();

}
function index(path, returnType) {
if (!isDirectory(path)) {
function index(path, type) {
if (!isDir(path)) {
return [];
}
const readdirResults = [];
function readdir(dirpath) {
const results = [];
function readdir(dir) {
try {
const readdirResult = readdirSync(dirpath, { encoding: "utf-8" });
for (let i = 0; i < readdirResult.length; i++) {
const resultPath = join(dirpath, readdirResult[i]);
const relativeResultPath = relative(path, resultPath);
const absolutePath = join(cwd(), resultPath);
const pushPath = returnType === "relativePath" ? resultPath : returnType === "absolutePath" ? absolutePath : relativeResultPath;
readdirResults.push(pushPath);
if (isDirectory(resultPath)) {
readdir(resultPath);
const result = readdirSync(dir, { encoding: "utf-8" });
for (let i = 0; i < result.length; i++) {
const rpath = join(dir, result[i]);
const rrpath = relative(path, rpath);
const apath = join(cwd(), rpath);
const ppath = type === "relativePath" ? rpath : type === "absolutePath" ? apath : rrpath;
results.push(ppath);
if (isDir(rpath)) {
readdir(rpath);
}

@@ -37,5 +37,5 @@ }

readdir(path);
return readdirResults;
return results;
}
export { index as default };
{
"name": "@lxf2513/readdir-sync-recursive",
"version": "1.2.2",
"version": "1.3.0",
"description": "Reads the contents of the directory synchronously and recursively.",

@@ -50,6 +50,6 @@ "type": "module",

"devDependencies": {
"@types/node": "^22.10.1",
"@types/node": "^22.10.6",
"prettier": "^3.4.2",
"typescript": "^5.7.2",
"unbuild": "^2.0.0"
"typescript": "^5.7.3",
"unbuild": "^3.3.1"
},

@@ -56,0 +56,0 @@ "publishConfig": {