2.6.3 • Published 6 days ago
@ffflorian/file-index v2.6.3
file-index
Generate a file index.
Prerequisites
Installation
ℹ️ This is a hybrid CommonJS / ESM module.
Run yarn add @ffflorian/file-index
or npm install @ffflorian/file-index
.
Usage
Definition
function generateIndex(directory: string): Promise<DirEntry>;
function generateIndexSync(directory: string): DirEntry;
interface FileEntry {
fullPath: string;
name: string;
size: number;
type: 'file';
}
interface LinkEntry {
fullPath: string;
name: string;
type: 'link';
}
interface DirEntry extends Entry {
directories: {[name: string]: DirEntry};
files: {[name: string]: FileEntry};
links: {[name: string]: LinkEntry};
type: 'directory';
}
YourFile.ts
import {generateIndex} from '@ffflorian/file-index';
generateIndex('./')
.then(index => {
// see result
})
.catch(error => console.error(error));
generateIndex('./', 5) // with depth of 5
.then(index => {
// see result
})
.catch(error => console.error(error));
Result
{
directories: {
'.github': {
directories: {},
files: {
'main.workflow': {
fullPath: '/home/user/file-index/.github/main.workflow',
name: 'main.workflow',
size: 1369,
type: 'file',
},
},
fullPath: '/home/user/file-index/.github/',
links: {},
name: '.github',
type: 'directory',
},
dist: {
directories: {},
files: {
'fileIndex.d.ts': {
fullPath: '/home/user/file-index/dist/fileIndex.d.ts',
name: 'fileIndex.d.ts',
size: 190,
type: 'file',
},
// ...
},
fullPath: '/home/user/file-index/dist/',
links: {},
name: 'dist',
type: 'directory',
},
src: {
directories: {},
files: {
'FileIndex.ts': {
fullPath: '/home/user/file-index/src/FileIndex.ts',
name: 'FileIndex.ts',
size: 2635,
type: 'file',
},
// ...
},
fullPath: '/home/user/file-index/src/',
links: {},
name: 'src',
type: 'directory',
},
// ...
},
fullPath: '/home/user/file-index/',
links: {},
name: 'file-index',
type: 'directory',
}
2.6.3
6 days ago
2.6.2
4 months ago
2.6.1
4 months ago
2.6.0
4 months ago
2.5.9
4 months ago
2.5.10
4 months ago
2.5.8
4 months ago
2.5.7
4 months ago
2.5.0
6 months ago
2.5.2
6 months ago
2.5.1
6 months ago
2.5.4
5 months ago
2.5.3
5 months ago
2.5.6
5 months ago
2.5.5
5 months ago
2.3.0
1 year ago
2.2.0
1 year ago
2.4.1
1 year ago
2.1.4
1 year ago
2.4.0
1 year ago
2.3.1
1 year ago
2.1.3
1 year ago
2.1.2
1 year ago
2.1.1
1 year ago
2.1.0
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.3.0
5 years ago
1.2.0
5 years ago
1.1.0
5 years ago
1.0.0
5 years ago
0.0.1
5 years ago