improves block functionality
adds cli compatible prompts/logs adds logfile function for debug adds multiselect support new fieldRename adds listFieldNames
This commit is contained in:
18
util/dedent.ts
Normal file
18
util/dedent.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export function dedent(str: string) {
|
||||
const lines = str.split("\n");
|
||||
const indent = lines.reduce((count, line) => {
|
||||
if (line.trim() === "") return count;
|
||||
const match = line.match(/^(\s*)/);
|
||||
return match ? Math.min(count, match[1].length) : count;
|
||||
}, Infinity);
|
||||
return lines.map((line) => line.slice(indent)).join("\n");
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
console.log(dedent(`
|
||||
Hello, World!
|
||||
This is a paragraph
|
||||
that spans multiple lines.
|
||||
And this is another paragraph.
|
||||
`));
|
||||
}
|
15
util/logfile.ts
Normal file
15
util/logfile.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
const logFile = Deno.openSync("./log.txt", {
|
||||
create: true,
|
||||
write: true,
|
||||
read: true,
|
||||
append: true,
|
||||
});
|
||||
|
||||
logFile.truncateSync(0);
|
||||
|
||||
export function log(message: any) {
|
||||
if (typeof message === "object") {
|
||||
message = JSON.stringify(message);
|
||||
}
|
||||
logFile.writeSync(new TextEncoder().encode(message + "\n"));
|
||||
}
|
Reference in New Issue
Block a user