-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect.ts
More file actions
30 lines (27 loc) · 801 Bytes
/
select.ts
File metadata and controls
30 lines (27 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { IDirEntry, IQuery } from "./types.ts";
import { where } from "./where.ts";
export async function select(query: IQuery): Promise<IDirEntry[]> {
const output: IDirEntry[] = [];
const entries = Deno.readDir(query.from);
try {
for await (const entry of entries) {
const row: IDirEntry = {
name: entry.name,
isFile: entry.isFile,
isDirectory: entry.isDirectory,
isSymlink: entry.isSymlink,
};
const path = `${query.from}/${entry.name}`;
const info = await Deno.lstat(path);
row.size = info.size;
row.accessedAt = info.atime;
row.createdAt = info.birthtime;
row.modifiedAt = info.mtime;
if (where(row, query.where)) {
output.push(row);
}
}
} catch (err) {
}
return output;
}