From f96824fd8d69030e982b86066861894b363fcf6e Mon Sep 17 00:00:00 2001 From: dojyorin Date: Sun, 30 Jun 2024 20:25:13 +0900 Subject: [PATCH 1/5] jsr support. --- deps.pure.ts | 6 ++---- deps.test.ts | 11 +++++------ deps.ts | 7 +++---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/deps.pure.ts b/deps.pure.ts index 1fdfbb9..cb29a2b 100644 --- a/deps.pure.ts +++ b/deps.pure.ts @@ -1,7 +1,5 @@ -// @deno-types="https://deno.land/std@0.224.0/csv/mod.ts" -export {parse, stringify} from "https://esm.sh/gh/denoland/deno_std@0.224.0/csv/mod.ts?bundle&target=esnext"; -// @deno-types="https://deno.land/x/zipjs@v2.7.45/index.d.ts" -export {ZipReader, ZipWriter, Uint8ArrayReader, Uint8ArrayWriter} from "https://esm.sh/gh/gildas-lormeau/zip.js@v2.7.45/index.js?bundle&target=esnext"; +export {parse, stringify} from "https://esm.sh/jsr/@std/csv@0.224.3?bundle&target=esnext"; +export {ZipReader, ZipWriter, Uint8ArrayReader, Uint8ArrayWriter} from "https://esm.sh/jsr/@zip-js/zip-js@2.7.45?bundle&target=esnext"; // @deno-types="https://cdn.sheetjs.com/xlsx-0.20.2/package/types/index.d.ts" export {type WorkBook as RawWorkBook, type WorkSheet as RawWorkSheet, type CellObject as RawWorkCell, set_cptable, read as xlsxRead, write as xlsxWrite, utils as xlsxUtil} from "https://cdn.sheetjs.com/xlsx-0.20.2/package/xlsx.mjs"; diff --git a/deps.test.ts b/deps.test.ts index d410a4b..a82f3f1 100644 --- a/deps.test.ts +++ b/deps.test.ts @@ -1,8 +1,7 @@ -export {assertEquals} from "https://deno.land/std@0.224.0/assert/mod.ts"; -export {dirname, fromFileUrl} from "https://deno.land/std@0.224.0/path/mod.ts"; -export {exists} from "https://deno.land/std@0.224.0/fs/mod.ts"; -export {delay} from "https://deno.land/std@0.224.0/async/mod.ts"; - -export {DOMParser} from "https://deno.land/x/deno_dom@v0.1.46/deno-dom-wasm.ts"; +export {assertEquals} from "jsr:@std/assert@0.226.0"; +export {dirname, fromFileUrl} from "jsr:@std/path@0.225.2"; +export {exists} from "jsr:@std/fs@0.229.3"; +export {delay} from "jsr:@std/async@0.224.2"; +export {DOMParser} from "jsr:@b-fuze/deno-dom@0.1.47"; export {init as smtpTest} from "npm:smtp-tester@2.1.0"; \ No newline at end of file diff --git a/deps.ts b/deps.ts index 875fb24..c6faf7b 100644 --- a/deps.ts +++ b/deps.ts @@ -1,7 +1,6 @@ -export {Logger, ConsoleHandler, FileHandler} from "https://deno.land/std@0.224.0/log/mod.ts"; -export {format} from "https://deno.land/std@0.224.0/datetime/mod.ts"; - -export {type Element, DOMParser} from "https://deno.land/x/deno_dom@v0.1.46/deno-dom-wasm.ts"; +export {Logger, ConsoleHandler, FileHandler} from "jsr:@std/log@0.224.3"; +export {format} from "jsr:@std/datetime@0.224.1"; +export {type Element, DOMParser} from "jsr:@b-fuze/deno-dom@0.1.47"; // @deno-types="npm:@types/nodemailer@6.4.15" export {createTransport} from "npm:nodemailer@6.9.13"; \ No newline at end of file From 116ff0c837649b8cae48c3688c40364a035ded66 Mon Sep 17 00:00:00 2001 From: dojyorin Date: Sun, 30 Jun 2024 20:43:33 +0900 Subject: [PATCH 2/5] change name --- mod.pure.full.ts | 2 +- mod.test.ts | 2 +- src/pure_ext/{excel.ts => sheet.ts} | 0 test/pure_ext/{excel.test.ts => sheet.test.ts} | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename src/pure_ext/{excel.ts => sheet.ts} (100%) rename test/pure_ext/{excel.test.ts => sheet.test.ts} (94%) diff --git a/mod.pure.full.ts b/mod.pure.full.ts index fc41fe5..3ce65e4 100644 --- a/mod.pure.full.ts +++ b/mod.pure.full.ts @@ -1,5 +1,5 @@ export * from "./mod.pure.ts"; export * from "./src/pure_ext/csv.ts"; -export * from "./src/pure_ext/excel.ts"; +export * from "./src/pure_ext/sheet.ts"; export * from "./src/pure_ext/zip.ts"; \ No newline at end of file diff --git a/mod.test.ts b/mod.test.ts index 1643eb5..db23a10 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -12,7 +12,7 @@ import "./test/pure/time.test.ts"; import "./test/pure/worker.test.ts"; import "./test/pure_ext/csv.test.ts"; -import "./test/pure_ext/excel.test.ts"; +import "./test/pure_ext/sheet.test.ts"; import "./test/pure_ext/zip.test.ts"; import "./test/deno/json.test.ts"; diff --git a/src/pure_ext/excel.ts b/src/pure_ext/sheet.ts similarity index 100% rename from src/pure_ext/excel.ts rename to src/pure_ext/sheet.ts diff --git a/test/pure_ext/excel.test.ts b/test/pure_ext/sheet.test.ts similarity index 94% rename from test/pure_ext/excel.test.ts rename to test/pure_ext/sheet.test.ts index 09b2939..f3b3704 100644 --- a/test/pure_ext/excel.test.ts +++ b/test/pure_ext/sheet.test.ts @@ -1,5 +1,5 @@ import {assertEquals} from "../../deps.test.ts"; -import {type RawWorkBook, excelEncodeRaw, excelEncode, excelDecodeRaw, excelDecode} from "../../src/pure_ext/excel.ts"; +import {type RawWorkBook, excelEncodeRaw, excelEncode, excelDecodeRaw, excelDecode} from "../../src/pure_ext/sheet.ts"; const sample1 = { "test": [ From b3ccdb39239a76b9c18ad95068ae5e6588d34718 Mon Sep 17 00:00:00 2001 From: dojyorin Date: Sun, 30 Jun 2024 20:50:08 +0900 Subject: [PATCH 3/5] sheet. --- deps.pure.ts | 4 ++-- src/pure_ext/sheet.ts | 38 ++++++++++++++++++------------------- test/pure_ext/sheet.test.ts | 10 +++++----- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/deps.pure.ts b/deps.pure.ts index cb29a2b..ab33395 100644 --- a/deps.pure.ts +++ b/deps.pure.ts @@ -2,5 +2,5 @@ export {parse, stringify} from "https://esm.sh/jsr/@std/csv@0.224.3?bundle&targe export {ZipReader, ZipWriter, Uint8ArrayReader, Uint8ArrayWriter} from "https://esm.sh/jsr/@zip-js/zip-js@2.7.45?bundle&target=esnext"; // @deno-types="https://cdn.sheetjs.com/xlsx-0.20.2/package/types/index.d.ts" -export {type WorkBook as RawWorkBook, type WorkSheet as RawWorkSheet, type CellObject as RawWorkCell, set_cptable, read as xlsxRead, write as xlsxWrite, utils as xlsxUtil} from "https://cdn.sheetjs.com/xlsx-0.20.2/package/xlsx.mjs"; -export * as xlsxcp from "https://cdn.sheetjs.com/xlsx-0.20.2/package/dist/cpexcel.full.mjs"; \ No newline at end of file +export {type WorkBook as RawWorkBook, type WorkSheet as RawWorkSheet, type CellObject as RawWorkCell, set_cptable, read as sheetRead, write as sheetWrite, utils as sheetUtil} from "https://cdn.sheetjs.com/xlsx-0.20.2/package/xlsx.mjs"; +export * as excelcp from "https://cdn.sheetjs.com/xlsx-0.20.2/package/dist/cpexcel.full.mjs"; \ No newline at end of file diff --git a/src/pure_ext/sheet.ts b/src/pure_ext/sheet.ts index f9335b5..6b1a584 100644 --- a/src/pure_ext/sheet.ts +++ b/src/pure_ext/sheet.ts @@ -1,9 +1,9 @@ -import {type RawWorkBook, type RawWorkSheet, type RawWorkCell, xlsxcp, set_cptable, xlsxRead, xlsxWrite, xlsxUtil} from "../../deps.pure.ts"; +import {type RawWorkBook, type RawWorkSheet, type RawWorkCell, excelcp, set_cptable, sheetRead, sheetWrite, sheetUtil} from "../../deps.pure.ts"; import {timeFormatSerialize} from "../pure/time.ts"; export type {RawWorkBook, RawWorkSheet, RawWorkCell}; -set_cptable(xlsxcp); +set_cptable(excelcp); /** * Convert from sheetjs raw workbook object to EXCEL workbook. @@ -11,12 +11,12 @@ set_cptable(xlsxcp); * @example * ```ts * const bin = await Deno.readFile("./book.xlsx"); -* const book = excelDecodeRaw(bin); -* const enc = excelEncodeRaw(book); +* const book = sheetDecodeRaw(bin); +* const enc = sheetEncodeRaw(book); * ``` */ -export function excelEncodeRaw(book:RawWorkBook, cp?:number, pw?:string):Uint8Array{ - const buf = xlsxWrite(book, { +export function sheetEncodeRaw(book:RawWorkBook, cp?:number, pw?:string):Uint8Array{ + const buf = sheetWrite(book, { type: "array", compression: true, cellStyles: true, @@ -33,11 +33,11 @@ export function excelEncodeRaw(book:RawWorkBook, cp?:number, pw?:string):Uint8Ar * @example * ```ts * const bin = await Deno.readFile("./book.xlsx"); -* const book = excelDecode(bin); -* const enc = excelEncode(book); +* const book = sheetDecode(bin); +* const enc = sheetEncode(book); * ``` */ -export function excelEncode(sheets:Record, cp?:number, pw?:string):Uint8Array{ +export function sheetEncode(sheets:Record, cp?:number, pw?:string):Uint8Array{ const book:Record = {}; for(const [name, sheet] of Object.entries(sheets)){ @@ -58,11 +58,11 @@ export function excelEncode(sheets:Record, cp?:number, pw?:s book[name] = { "!data": rows, - "!ref": `A1:${xlsxUtil.encode_col(rows.reduce((v, {length}) => Math.max(v, length), -Infinity))}${rows.length}` + "!ref": `A1:${sheetUtil.encode_col(rows.reduce((v, {length}) => Math.max(v, length), -Infinity))}${rows.length}` }; } - return excelEncodeRaw({ + return sheetEncodeRaw({ SheetNames: Object.keys(sheets), Sheets: book }, cp, pw); @@ -74,12 +74,12 @@ export function excelEncode(sheets:Record, cp?:number, pw?:s * @example * ```ts * const bin = await Deno.readFile("./book.xlsx"); -* const book = excelDecodeRaw(bin); -* const enc = excelEncodeRaw(book); +* const book = sheetDecodeRaw(bin); +* const enc = sheetEncodeRaw(book); * ``` */ -export function excelDecodeRaw(data:Uint8Array, cp?:number, pw?:string):RawWorkBook{ - return xlsxRead(data, { +export function sheetDecodeRaw(data:Uint8Array, cp?:number, pw?:string):RawWorkBook{ + return sheetRead(data, { type: "array", dense: true, raw: true, @@ -95,12 +95,12 @@ export function excelDecodeRaw(data:Uint8Array, cp?:number, pw?:string):RawWorkB * @example * ```ts * const bin = await Deno.readFile("./book.xlsx"); -* const book = excelDecode(bin); -* const enc = excelEncode(book); +* const book = sheetDecode(bin); +* const enc = sheetEncode(book); * ``` */ -export function excelDecode(data:Uint8Array, cp?:number, pw?:string):Record{ - const {Sheets} = excelDecodeRaw(data, cp, pw); +export function sheetDecode(data:Uint8Array, cp?:number, pw?:string):Record{ + const {Sheets} = sheetDecodeRaw(data, cp, pw); const book:Record = {}; diff --git a/test/pure_ext/sheet.test.ts b/test/pure_ext/sheet.test.ts index f3b3704..0ddc1ab 100644 --- a/test/pure_ext/sheet.test.ts +++ b/test/pure_ext/sheet.test.ts @@ -1,5 +1,5 @@ import {assertEquals} from "../../deps.test.ts"; -import {type RawWorkBook, excelEncodeRaw, excelEncode, excelDecodeRaw, excelDecode} from "../../src/pure_ext/sheet.ts"; +import {type RawWorkBook, sheetEncodeRaw, sheetEncode, sheetDecodeRaw, sheetDecode} from "../../src/pure_ext/sheet.ts"; const sample1 = { "test": [ @@ -31,8 +31,8 @@ const sample2:RawWorkBook = { Deno.test({ name: "EXCEL: Encode and Decode", fn(){ - const encode = excelEncode(sample1); - const decode = excelDecode(encode); + const encode = sheetEncode(sample1); + const decode = sheetDecode(encode); assertEquals(decode, sample1); } @@ -41,8 +41,8 @@ Deno.test({ Deno.test({ name: "EXCEL: Raw Encode and Decode", fn(){ - const encode = excelEncodeRaw(sample2); - const decode = excelDecodeRaw(encode); + const encode = sheetEncodeRaw(sample2); + const decode = sheetDecodeRaw(encode); assertEquals(decode.Sheets, sample2.Sheets); } From d3b204383ec8e9454e0355cc4d5404efa2ee285d Mon Sep 17 00:00:00 2001 From: dojyorin Date: Mon, 1 Jul 2024 23:38:15 +0900 Subject: [PATCH 4/5] code format. --- mod.full.ts | 2 - mod.test.ts | 2 - mod.ts | 2 - src/deno/json.ts | 16 +++---- src/deno/os.ts | 26 ----------- src/deno/path.ts | 88 ------------------------------------- src/deno/process.ts | 2 +- src/deno_ext/dom.ts | 32 +++++++------- src/deno_ext/log.ts | 12 ++--- src/deno_ext/smtp.ts | 6 +-- src/pure/base64.ts | 4 +- src/pure/byte.ts | 4 +- src/pure/crypto.ts | 26 +++++------ src/pure/deep.ts | 14 +++--- src/pure/deflate.ts | 4 +- src/pure/fetch.ts | 6 +-- src/pure/minipack.ts | 8 ++-- src/pure/primitive.ts | 14 +++--- src/pure/stream.ts | 4 +- src/pure/text.ts | 18 ++++---- src/pure/time.ts | 12 ++--- src/pure/worker.ts | 18 ++++---- src/pure_ext/csv.ts | 8 ++-- src/pure_ext/sheet.ts | 30 ++++++------- src/pure_ext/zip.ts | 10 ++--- test/deno/json.test.ts | 4 +- test/deno/os.test.ts | 32 -------------- test/deno/path.test.ts | 40 ----------------- test/deno/process.test.ts | 2 +- test/deno_ext/dom.test.ts | 14 +++--- test/deno_ext/log.test.ts | 2 +- test/deno_ext/smtp.test.ts | 6 +-- test/pure/base64.test.ts | 4 +- test/pure/byte.test.ts | 2 +- test/pure/crypto.test.ts | 8 ++-- test/pure/deep.test.ts | 4 +- test/pure/deflate.test.ts | 2 +- test/pure/fetch.test.ts | 2 +- test/pure/minipack.test.ts | 2 +- test/pure/primitive.test.ts | 4 +- test/pure/stream.test.ts | 2 +- test/pure/text.test.ts | 14 +++--- test/pure/time.test.ts | 6 +-- test/pure/worker.test.ts | 4 +- test/pure_ext/csv.test.ts | 2 +- test/pure_ext/sheet.test.ts | 4 +- test/pure_ext/zip.test.ts | 2 +- 47 files changed, 167 insertions(+), 363 deletions(-) delete mode 100644 src/deno/os.ts delete mode 100644 src/deno/path.ts delete mode 100644 test/deno/os.test.ts delete mode 100644 test/deno/path.test.ts diff --git a/mod.full.ts b/mod.full.ts index 20cdae6..70fc593 100644 --- a/mod.full.ts +++ b/mod.full.ts @@ -1,8 +1,6 @@ export * from "./mod.pure.full.ts"; export * from "./src/deno/json.ts"; -export * from "./src/deno/os.ts"; -export * from "./src/deno/path.ts"; export * from "./src/deno/process.ts"; export * from "./src/deno_ext/dom.ts"; diff --git a/mod.test.ts b/mod.test.ts index db23a10..aa7cc8e 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -16,8 +16,6 @@ import "./test/pure_ext/sheet.test.ts"; import "./test/pure_ext/zip.test.ts"; import "./test/deno/json.test.ts"; -import "./test/deno/os.test.ts"; -import "./test/deno/path.test.ts"; import "./test/deno/process.test.ts"; import "./test/deno_ext/dom.test.ts"; diff --git a/mod.ts b/mod.ts index 985afb1..3c4fae2 100644 --- a/mod.ts +++ b/mod.ts @@ -1,6 +1,4 @@ export * from "./mod.pure.ts"; export * from "./src/deno/json.ts"; -export * from "./src/deno/os.ts"; -export * from "./src/deno/path.ts"; export * from "./src/deno/process.ts"; \ No newline at end of file diff --git a/src/deno/json.ts b/src/deno/json.ts index 4b065c8..4472b19 100644 --- a/src/deno/json.ts +++ b/src/deno/json.ts @@ -7,7 +7,7 @@ import {type Opt} from "../pure/deep.ts"; * const json = await jsonRead("./data.json"); * ``` */ -export async function jsonRead>(path:string):Promise{ +export async function jsonRead>(path:string):Promise { return JSON.parse(await Deno.readTextFile(path)); } @@ -20,7 +20,7 @@ export async function jsonRead>(path:string):Promise{ * }); * ``` */ -export async function jsonWrite>(path:string, data:T):Promise{ +export async function jsonWrite>(path:string, data:T):Promise { await Deno.writeTextFile(path, JSON.stringify(data, undefined, 4)); } @@ -34,15 +34,13 @@ export async function jsonWrite>(path:string, data:T):Promise>(path:string, def:T):Promise{ - try{ +export async function jsonLoad>(path:string, def:T):Promise { + try { return await jsonRead(path); - } - catch(e){ - if(e instanceof Deno.errors.NotFound){ + } catch(e) { + if(e instanceof Deno.errors.NotFound) { await jsonWrite(path, def); - } - else{ + } else { throw e; } } diff --git a/src/deno/os.ts b/src/deno/os.ts deleted file mode 100644 index 44a1ad8..0000000 --- a/src/deno/os.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** -* Are you running on Windows? -* @example -* ```ts -* const isWin = osWin; -* ``` -*/ -export const osWindows:boolean = Deno.build.os === "windows"; - -/** -* Are you running on Mac? -* @example -* ```ts -* const isMac = osMac; -* ``` -*/ -export const osMac:boolean = Deno.build.os === "darwin"; - -/** -* Are you running on Linux? -* @example -* ```ts -* const isLinux = osLinux; -* ``` -*/ -export const osLinux:boolean = Deno.build.os === "linux"; \ No newline at end of file diff --git a/src/deno/path.ts b/src/deno/path.ts deleted file mode 100644 index b4b18d2..0000000 --- a/src/deno/path.ts +++ /dev/null @@ -1,88 +0,0 @@ -import {osWindows} from "./os.ts"; - -/** -* Convert from backslash to slash. -* Useful for converting from Windows path to UNIX path. -* @example -* ```ts -* const path = pathSepL("C:\\file"); -* ``` -*/ -export function pathSepL(path:string):string{ - return path.replace(/\\/g, "/"); -} - -/** -* Convert from slash to backslash. -* Useful for converting from UNIX path to Windows path. -* @example -* ```ts -* const path = pathSepW("C:/file"); -* ``` -*/ -export function pathSepW(path:string):string{ - return path.replace(/\//g, "\\"); -} - -/** -* System-wide temporary directory path for each OS. -* `/tmp` for UNIX and `C:/Windows/Temp` for Windows. -* @example -* ```ts -* const path = pathTmp(); -* ``` -*/ -export function pathTmp():string{ - return osWindows ? "C:/Windows/Temp" : "/tmp"; -} - -/** -* System-wide application data directory path for each OS. -* `/var` for UNIX and `C:/ProgramData` for Windows. -* @example -* ```ts -* const path = pathVar(); -* ``` -*/ -export function pathVar():string{ - return osWindows ? "C:/ProgramData" : "/var"; -} - -/** -* System-wide user config directory path for each OS. -* `~/.config` for UNIX and `~/AppData/Roaming` for Windows. -* @example -* ```ts -* const path = pathConfig(); -* ``` -*/ -export function pathConfig():string{ - return `${pathHome()}/${osWindows ? "AppData/Roaming" : ".config"}`; -} - -/** -* System-wide home directory path for each OS. -* `${HOME}` for UNIX and `%USERPROFILE%` for Windows. -* @example -* ```ts -* const path = pathHome(); -* ``` -*/ -export function pathHome():string{ - const {HOME, USERPROFILE} = Deno.env.toObject(); - - return osWindows ? pathSepL(USERPROFILE) : HOME; -} - -/** -* Directory of `Deno.mainModule`. -* @example -* ```ts -* const path = pathMain(); -* ``` -*/ -export function pathMain():string{ - const directory = new URL(Deno.mainModule).pathname.replace(/[^/]*$/, ""); - - return osWindows ? directory.replace(/^\//, "") : directory; -} \ No newline at end of file diff --git a/src/deno/process.ts b/src/deno/process.ts index 86f00b5..1fb3690 100644 --- a/src/deno/process.ts +++ b/src/deno/process.ts @@ -5,7 +5,7 @@ * const success = await processRun("echo", "foobar"); * ``` */ -export async function processRun(...commands:string[]):Promise{ +export async function processRun(...commands:string[]):Promise { const {success} = await new Deno.Command(commands.shift() ?? "", { args: commands, stdin: "null", diff --git a/src/deno_ext/dom.ts b/src/deno_ext/dom.ts index 8f1ed73..e27f2bf 100644 --- a/src/deno_ext/dom.ts +++ b/src/deno_ext/dom.ts @@ -1,15 +1,15 @@ import {type Element, DOMParser} from "../../deps.ts"; -function selectedElement(elements:Element[], attribute:"checked" | "selected"){ +function selectedElement(elements:Element[], attribute:"checked" | "selected") { return elements.find(v => typeof v.getAttribute(attribute) === "string"); } -function getValue(element?:Element){ +function getValue(element?:Element) { return element?.getAttribute("value") ?? ""; } -function extractValue(element?:Element){ - switch(element?.tagName){ +function extractValue(element?:Element) { + switch(element?.tagName) { case "SELECT": return getValue(selectedElement(element.getElementsByTagName("option"), "selected")); case "DATALIST": return getValue(selectedElement(element.getElementsByTagName("option"), "selected")); case "OPTION": return getValue(element); @@ -27,10 +27,10 @@ function extractValue(element?:Element){ * const dom = domDecode("
foo
"); * ``` */ -export function domDecode(html:string):Element{ +export function domDecode(html:string):Element { const element = new DOMParser().parseFromString(html, "text/html")?.documentElement; - if(!element){ + if(!element) { throw new Error(); } @@ -45,19 +45,19 @@ export function domDecode(html:string):Element{ * const result = domValuesPerId(dom); * ``` */ -export function domValuesPerId(element:Element):Record{ +export function domValuesPerId(element:Element):Record { const records:Record = {}; - for(const input of element.getElementsByTagName("INPUT")){ - if(!input.id){ + for(const input of element.getElementsByTagName("INPUT")) { + if(!input.id) { continue; } records[input.id] = getValue(input); } - for(const textarea of element.getElementsByTagName("TEXTAREA")){ - if(!textarea.id){ + for(const textarea of element.getElementsByTagName("TEXTAREA")) { + if(!textarea.id) { continue; } @@ -76,7 +76,7 @@ export function domValuesPerId(element:Element):Record{ * const result = domValueById(dom, "foo"); * ``` */ -export function domValueById(element:Element, id:string):string{ +export function domValueById(element:Element, id:string):string { return extractValue(element.getElementById(id) ?? undefined); } @@ -88,7 +88,7 @@ export function domValueById(element:Element, id:string):string{ * const result = domElementsByName(dom, "foo"); * ``` */ -export function domElementsByName(element:Element, name:string):Element[]{ +export function domElementsByName(element:Element, name:string):Element[] { return element.getElementsByTagName("*").filter(v => v.getAttribute("name") === name); } @@ -101,7 +101,7 @@ export function domElementsByName(element:Element, name:string):Element[]{ * const result = domValuesByName(dom, "foo"); * ``` */ -export function domValuesByName(element:Element, name:string):string[]{ +export function domValuesByName(element:Element, name:string):string[] { return domElementsByName(element, name).map(v => extractValue(v)); } @@ -113,10 +113,10 @@ export function domValuesByName(element:Element, name:string):string[]{ * const result = domValueByRadioActive(dom, "foo"); * ``` */ -export function domValueByRadioActive(element:Element, name:string):string{ +export function domValueByRadioActive(element:Element, name:string):string { const elements = domElementsByName(element, name); - if(elements.some(v => v.tagName !== "INPUT" || v.getAttribute("type") !== "radio")){ + if(elements.some(v => v.tagName !== "INPUT" || v.getAttribute("type") !== "radio")) { return ""; } diff --git a/src/deno_ext/log.ts b/src/deno_ext/log.ts index 8b550b2..85d474d 100644 --- a/src/deno_ext/log.ts +++ b/src/deno_ext/log.ts @@ -1,6 +1,6 @@ import {Logger, ConsoleHandler, FileHandler, format} from "../../deps.ts"; -function logRecord(date:Date, level:string, message:string){ +function logRecord(date:Date, level:string, message:string) { return `${format(date, "yyyy-MM-ddTHH:mm:ss")} [${level}] ${message}`; } @@ -13,31 +13,31 @@ function logRecord(date:Date, level:string, message:string){ * const log = logEntry(); * ``` */ -export function logEntry(name?:string, path?:string):Logger{ +export function logEntry(name?:string, path?:string):Logger { const level = "INFO"; const log = new Logger(name ?? "log", level, { handlers: [ new ConsoleHandler(level, { - formatter({datetime, levelName, msg}){ + formatter({datetime, levelName, msg}) { return logRecord(datetime, levelName, msg); } }) ] }); - if(path){ + if(path) { log.handlers.push( new FileHandler(level, { filename: path, - formatter({datetime, levelName, msg}){ + formatter({datetime, levelName, msg}) { return logRecord(datetime, levelName, msg); } }) ); } - for(const h of log.handlers){ + for(const h of log.handlers) { h.setup(); } diff --git a/src/deno_ext/smtp.ts b/src/deno_ext/smtp.ts index e54e526..0116d7f 100644 --- a/src/deno_ext/smtp.ts +++ b/src/deno_ext/smtp.ts @@ -27,10 +27,10 @@ export interface MailMessage { * }); * ``` */ -export async function smtpSend(path:string, message:MailMessage):Promise{ +export async function smtpSend(path:string, message:MailMessage):Promise { const {protocol, hostname, port, username, password} = new URL(path); - if(protocol !== "smtp:" && protocol !== "smtps:"){ + if(protocol !== "smtp:" && protocol !== "smtps:") { throw new Error(protocol); } @@ -51,7 +51,7 @@ export async function smtpSend(path:string, message:MailMessage):Promise{ bcc: message.bcc, subject: message.title, text: message.body, - attachments: message.files?.map(({name, body}) => ({filename: name, content: body})) + attachments: message.files?.map(({name, body}) => ({filename: name, content: body})) }); smtp.close(); diff --git a/src/pure/base64.ts b/src/pure/base64.ts index 4153418..c228141 100644 --- a/src/pure/base64.ts +++ b/src/pure/base64.ts @@ -7,7 +7,7 @@ * const decode = base64Decode(encode); * ``` */ -export function base64Encode(data:Uint8Array):string{ +export function base64Encode(data:Uint8Array):string { return btoa(Array.from(data, v => String.fromCharCode(v)).join("")); } @@ -20,6 +20,6 @@ export function base64Encode(data:Uint8Array):string{ * const decode = base64Decode(encode); * ``` */ -export function base64Decode(data:string):Uint8Array{ +export function base64Decode(data:string):Uint8Array { return new Uint8Array(Array.from(atob(data), v => v.charCodeAt(0))); } \ No newline at end of file diff --git a/src/pure/byte.ts b/src/pure/byte.ts index 950ff18..2826b1c 100644 --- a/src/pure/byte.ts +++ b/src/pure/byte.ts @@ -5,11 +5,11 @@ * const byte = byteConcat(new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])); * ``` */ -export function byteConcat(...sources:BufferSource[]):Uint8Array{ +export function byteConcat(...sources:BufferSource[]):Uint8Array { const output = new Uint8Array(sources.reduce((v, {byteLength}) => v + byteLength , 0)); let i = 0; - for(const source of sources){ + for(const source of sources) { output.set(new Uint8Array("buffer" in source ? source.buffer : source), i); i += source.byteLength; } diff --git a/src/pure/crypto.ts b/src/pure/crypto.ts index dec54e9..dfb8118 100644 --- a/src/pure/crypto.ts +++ b/src/pure/crypto.ts @@ -15,16 +15,16 @@ const CURVE_DSA = Object.freeze({ hash: "SHA-256" }); -async function generateKey(alg:EcKeyAlgorithm, usage:KeyUsage[]){ +async function generateKey(alg:EcKeyAlgorithm, usage:KeyUsage[]):Promise { const {publicKey, privateKey} = await crypto.subtle.generateKey(alg, true, usage); - return { + return { pub: new Uint8Array(await crypto.subtle.exportKey("spki", publicKey)), key: new Uint8Array(await crypto.subtle.exportKey("pkcs8", privateKey)) }; } -async function deriveKey(pub:Uint8Array, key:Uint8Array){ +async function deriveKey(pub:Uint8Array, key:Uint8Array):Promise { return await crypto.subtle.deriveKey({ name: CURVE_KEX.name, public: await crypto.subtle.importKey("spki", pub, CURVE_KEX, false, []) @@ -41,7 +41,7 @@ async function deriveKey(pub:Uint8Array, key:Uint8Array){ * const random = cryptoRandom(16); * ``` */ -export function cryptoRandom(n:number):Uint8Array{ +export function cryptoRandom(n:number):Uint8Array { return crypto.getRandomValues(new Uint8Array(n)); } @@ -54,7 +54,7 @@ export function cryptoRandom(n:number):Uint8Array{ * const hash = await cryptoHash(bin); * ``` */ -export async function cryptoHash(data:Uint8Array, alg?:string):Promise{ +export async function cryptoHash(data:Uint8Array, alg?:string):Promise { return new Uint8Array(await crypto.subtle.digest(alg ?? "SHA-256", data)); } @@ -68,7 +68,7 @@ export async function cryptoHash(data:Uint8Array, alg?:string):Promise{ +export async function cryptoGenerateEncryptKey():Promise { return await generateKey(CURVE_KEX, ["deriveKey"]); } @@ -81,7 +81,7 @@ export async function cryptoGenerateEncryptKey():Promise{ * const {pub, key} = await cryptoGenerateSignKey(); * ``` */ -export async function cryptoGenerateSignKey():Promise{ +export async function cryptoGenerateSignKey():Promise { return await generateKey(CURVE_DSA, ["sign", "verify"]); } @@ -98,8 +98,8 @@ export async function cryptoGenerateSignKey():Promise{ * const decrypt = await cryptoDecrypt(encrypt, key2.pub, key1.key); * ``` */ -export async function cryptoEncrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Array):Promise{ - const aes = { +export async function cryptoEncrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Array):Promise { + const aes:AesGcmParams = { name: AES_MODE, iv: cryptoRandom(12) }; @@ -120,8 +120,8 @@ export async function cryptoEncrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Ar * const decrypt = await cryptoDecrypt(encrypt, key2.pub, key1.key); * ``` */ -export async function cryptoDecrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Array):Promise{ - const aes = { +export async function cryptoDecrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Array):Promise { + const aes:AesGcmParams = { name: AES_MODE, iv: data.subarray(0, 12) }; @@ -139,7 +139,7 @@ export async function cryptoDecrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Ar * const verify = await cryptoVerify(bin, pub, sign); * ``` */ -export async function cryptoSign(data:Uint8Array, key:Uint8Array):Promise{ +export async function cryptoSign(data:Uint8Array, key:Uint8Array):Promise { return new Uint8Array(await crypto.subtle.sign(CURVE_DSA, await crypto.subtle.importKey("pkcs8", key, CURVE_DSA, false, ["sign"]), data)); } @@ -153,6 +153,6 @@ export async function cryptoSign(data:Uint8Array, key:Uint8Array):Promise{ +export async function cryptoVerify(data:Uint8Array, pub:Uint8Array, sign:Uint8Array):Promise { return await crypto.subtle.verify(CURVE_DSA, await crypto.subtle.importKey("spki", pub, CURVE_DSA, false, ["verify"]), sign, data); } \ No newline at end of file diff --git a/src/pure/deep.ts b/src/pure/deep.ts index 9346ccd..66db8f6 100644 --- a/src/pure/deep.ts +++ b/src/pure/deep.ts @@ -3,7 +3,7 @@ */ export type Opt = Partial>; -function hasObject(data:Record, key:string){ +function hasObject(data:Record, key:string) { return Object.hasOwn(data, key) && typeof data[key] === "object" && data[key] !== null; } @@ -18,11 +18,11 @@ function hasObject(data:Record, key:string){ * }); * ``` */ -export function deepFreeze>(data:T):Readonly{ +export function deepFreeze>(data:T):Readonly { Object.freeze(data); - for(const key in data){ - if(hasObject(data, key) && !Object.isFrozen(data[key])){ + for(const key in data) { + if(hasObject(data, key) && !Object.isFrozen(data[key])) { deepFreeze(data[key]); } } @@ -41,11 +41,11 @@ export function deepFreeze>(data:T):Readonly{ * }); * ``` */ -export function deepSeal>(data:T):T{ +export function deepSeal>(data:T):T { Object.seal(data); - for(const key in data){ - if(hasObject(data, key) && !Object.isSealed(data[key])){ + for(const key in data) { + if(hasObject(data, key) && !Object.isSealed(data[key])) { deepSeal(data[key]); } } diff --git a/src/pure/deflate.ts b/src/pure/deflate.ts index 8ed86c3..3646bf5 100644 --- a/src/pure/deflate.ts +++ b/src/pure/deflate.ts @@ -12,7 +12,7 @@ const COMPRESS_CODEC = "deflate-raw"; * const decode = await deflateDecode(encode); * ``` */ -export async function deflateEncode(data:Uint8Array, codec?:string):Promise{ +export async function deflateEncode(data:Uint8Array, codec?:string):Promise { return await streamDecode(streamEncode(data).pipeThrough(new CompressionStream(codec ?? COMPRESS_CODEC))); } @@ -26,6 +26,6 @@ export async function deflateEncode(data:Uint8Array, codec?:string):Promise{ +export async function deflateDecode(data:Uint8Array, codec?:string):Promise { return await streamDecode(streamEncode(data).pipeThrough(new DecompressionStream(codec ?? COMPRESS_CODEC))); } \ No newline at end of file diff --git a/src/pure/fetch.ts b/src/pure/fetch.ts index 54fbfc9..9c3c579 100644 --- a/src/pure/fetch.ts +++ b/src/pure/fetch.ts @@ -29,11 +29,11 @@ export interface FetchInit extends Omit { * const response = await fetchExtend("./asset", "byte"); * ``` */ -export async function fetchExtend(path:string, type:T, option?:FetchInit):Promise{ +export async function fetchExtend(path:string, type:T, option?:FetchInit):Promise { const u = new URL(path, globalThis?.location?.href); u.hash = ""; - for(const [k, v] of option?.query ?? []){ + for(const [k, v] of option?.query ?? []) { u.searchParams.set(k, v); } @@ -51,7 +51,7 @@ export async function fetchExtend(path:string, typ body: option?.body }); - switch(type){ + switch(type) { case "text": return await response.text(); case "json": return await response.json(); case "form": return await response.formData(); diff --git a/src/pure/minipack.ts b/src/pure/minipack.ts index 9b0a479..e6c4db7 100644 --- a/src/pure/minipack.ts +++ b/src/pure/minipack.ts @@ -24,11 +24,11 @@ export interface DataMap { * const decode = minipackDecode(encode); * ``` */ -export function minipackEncode(files:DataMap[]):Uint8Array{ +export function minipackEncode(files:DataMap[]):Uint8Array { const archive = new Uint8Array(files.reduce((size, {name, body}) => size + NAME_SIZE + BODY_SIZE + textEncode(name).byteLength + body.byteLength, 0)); let i = 0; - for(const {name, body} of files){ + for(const {name, body} of files) { const u8name = textEncode(name); new DataView(archive.buffer, i).setUint8(0, u8name.byteLength); @@ -60,10 +60,10 @@ export function minipackEncode(files:DataMap[]):Uint8Array{ * const decode = minipackDecode(encode); * ``` */ -export function minipackDecode(archive:Uint8Array):DataMap[]{ +export function minipackDecode(archive:Uint8Array):DataMap[] { const files:DataMap[] = []; - for(let i = 0; i < archive.byteLength;){ + for(let i = 0; i < archive.byteLength;) { const ns = new DataView(archive.buffer, i).getUint8(0); i += NAME_SIZE; diff --git a/src/pure/primitive.ts b/src/pure/primitive.ts index c68ee9e..13fc5a5 100644 --- a/src/pure/primitive.ts +++ b/src/pure/primitive.ts @@ -8,7 +8,7 @@ interface TypeMap { "boolean": boolean; } -function strictUndef(strict?:boolean){ +function strictUndef(strict?:boolean) { if(strict){ throw new Error(); } @@ -24,12 +24,12 @@ function strictUndef(strict?:boolean){ * const value = primitiveParse("123", "number", true); * ``` */ -export function primitiveParse(text:MaybeString, type:T, strict?:U):TypeStrict{ - if(text === undefined || text === null){ +export function primitiveParse(text:MaybeString, type:T, strict?:U):TypeStrict { + if(text === undefined || text === null) { return >strictUndef(strict); } - switch(type){ + switch(type) { case "string": return >text.toString(); case "number": return >parseInt(text); case "boolean": return >(text === "true"); @@ -46,12 +46,12 @@ export function primitiveParse(text: * const value = primitiveParseX("123", 0); * ``` */ -export function primitiveParseX(text:MaybeString, def:T):WidenLiteral{ - if(text === undefined || text === null){ +export function primitiveParseX(text:MaybeString, def:T):WidenLiteral { + if(text === undefined || text === null) { return >def; } - switch(typeof def){ + switch(typeof def) { case "string": return >text.toString(); case "number": return >parseInt(text); case "boolean": return >(text === "true"); diff --git a/src/pure/stream.ts b/src/pure/stream.ts index 7fe0a30..6ec3421 100644 --- a/src/pure/stream.ts +++ b/src/pure/stream.ts @@ -6,7 +6,7 @@ * const data = await streamDecode(stream); * ``` */ -export function streamEncode(...data:Uint8Array[]):ReadableStream{ +export function streamEncode(...data:Uint8Array[]):ReadableStream { return new Blob(data).stream(); } @@ -18,6 +18,6 @@ export function streamEncode(...data:Uint8Array[]):ReadableStream{ * const data = await streamDecode(stream); * ``` */ -export async function streamDecode(rs:ReadableStream):Promise{ +export async function streamDecode(rs:ReadableStream):Promise { return new Uint8Array(await new Blob(await Array.fromAsync(rs)).arrayBuffer()); } \ No newline at end of file diff --git a/src/pure/text.ts b/src/pure/text.ts index 907b146..f031b52 100644 --- a/src/pure/text.ts +++ b/src/pure/text.ts @@ -7,7 +7,7 @@ * const decode = textDecode(encode); * ``` */ -export function textEncode(data:string):Uint8Array{ +export function textEncode(data:string):Uint8Array { return new TextEncoder().encode(data); } @@ -20,7 +20,7 @@ export function textEncode(data:string):Uint8Array{ * const decode = textDecode(encode); * ``` */ -export function textDecode(data:Uint8Array, codec?:string):string{ +export function textDecode(data:Uint8Array, codec?:string):string { return new TextDecoder(codec).decode(data); } @@ -33,7 +33,7 @@ export function textDecode(data:Uint8Array, codec?:string):string{ * const decode = textHexDecode(encode); * ``` */ -export function textHexEncode(data:Uint8Array):string{ +export function textHexEncode(data:Uint8Array):string { return Array.from(data, v => textPadZero(v, 2, 16)).join(""); } @@ -46,7 +46,7 @@ export function textHexEncode(data:Uint8Array):string{ * const decode = textHexDecode(encode); * ``` */ -export function textHexDecode(data:string):Uint8Array{ +export function textHexDecode(data:string):Uint8Array { return new Uint8Array(data.match(/[0-9a-fA-F]{2}/g)?.map(v => parseInt(v, 16)) ?? []); } @@ -57,7 +57,7 @@ export function textHexDecode(data:string):Uint8Array{ * const format = textPurgeSuperfluous(" Lorem ipsum\r dolor sit \r\r amet. "); * ``` */ -export function textPurgeSuperfluous(data:string):string{ +export function textPurgeSuperfluous(data:string):string { return data.trim().replace(/\r/g, "").replace(/ +/g, " ").replace(/\t+/g, "\t").replace(/\n+/g, "\n").replace(/^ /mg, "").replace(/ $/mg, ""); } @@ -68,7 +68,7 @@ export function textPurgeSuperfluous(data:string):string{ * const format = textFixWidth("1+1=2"); * ``` */ -export function textFixWidth(data:string):string{ +export function textFixWidth(data:string):string { return Object.entries({ "ヴ": "ヴ", "ガ": "ガ", "ギ": "ギ", "グ": "グ", "ゲ": "ゲ", "ゴ": "ゴ", @@ -107,7 +107,7 @@ export function textFixWidth(data:string):string{ * const format = textGetReady("1 + 1 = 2 "); * ``` */ -export function textGetReady(data:string):string{ +export function textGetReady(data:string):string { return textPurgeSuperfluous(textFixWidth(data)); } @@ -119,7 +119,7 @@ export function textGetReady(data:string):string{ * const emojis = textSplitBySegment("😀😃😄😁😆😅😂🤣"); * ``` */ -export function textSplitBySegment(data:string):string[]{ +export function textSplitBySegment(data:string):string[] { return Array.from(new Intl.Segmenter().segment(data), ({segment}) => segment); } @@ -131,6 +131,6 @@ export function textSplitBySegment(data:string):string[]{ * const pad = textPadZero(8); * ``` */ -export function textPadZero(data:number, digit?:number, radix?:number):string{ +export function textPadZero(data:number, digit?:number, radix?:number):string { return data.toString(radix).padStart(digit ?? 2, "0"); } \ No newline at end of file diff --git a/src/pure/time.ts b/src/pure/time.ts index 5caca3b..73caad3 100644 --- a/src/pure/time.ts +++ b/src/pure/time.ts @@ -1,6 +1,6 @@ import {textPadZero} from "./text.ts"; -function dateFormat(date:string){ +function dateFormat(date:string) { const [y, m, d, h, mi, s] = date.split(/[/ :TZ_.-]/i).map(v => parseInt(v)); return new Date(y, (m ?? 1) - 1, d ?? 1, h ?? 0, mi ?? 0, s ?? 0); @@ -14,7 +14,7 @@ function dateFormat(date:string){ * await delay(1000); * ``` */ -export async function delay(time:number):Promise{ +export async function delay(time:number):Promise { const t0 = performance.now(); await new Promise(done => setTimeout(done, time)); const t1 = performance.now(); @@ -32,7 +32,7 @@ export async function delay(time:number):Promise{ * const date = timeDecode(time); * ``` */ -export function timeEncode(dt?:Date | string):number{ +export function timeEncode(dt?:Date | string):number { return Math.floor((dt instanceof Date ? dt : typeof dt === "string" ? dateFormat(dt) : new Date()).getTime() / 1000); } @@ -46,8 +46,8 @@ export function timeEncode(dt?:Date | string):number{ * const date = timeDecode(time); * ``` */ -export function timeDecode(dt?:number | string):Date{ - switch(typeof dt){ +export function timeDecode(dt?:number | string):Date { + switch(typeof dt) { case "string": return dateFormat(dt); case "number": return new Date(dt * 1000); default: return new Date(); @@ -62,7 +62,7 @@ export function timeDecode(dt?:number | string):Date{ * const format = timeFormatSerialize(); * ``` */ -export function timeFormatSerialize(dt?:Date | number | string, split?:boolean):string{ +export function timeFormatSerialize(dt?:Date | number | string, split?:boolean):string { const ss = split ? "/" : ""; const sc = split ? ":" : ""; const date = dt instanceof Date ? dt : timeDecode(dt); diff --git a/src/pure/worker.ts b/src/pure/worker.ts index bc25497..76fc470 100644 --- a/src/pure/worker.ts +++ b/src/pure/worker.ts @@ -22,7 +22,7 @@ export type TaskContext = (message:T, tran * `import` can only use "syntax", not "declaration". * @example * ```ts -* const task = workerTask(async(data)=>{ +* const task = workerTask(async (data) => { * const {delay} = await import("https://deno.land/std/async/mod.ts"); * await delay(data); * return { @@ -33,33 +33,33 @@ export type TaskContext = (message:T, tran * const result2 = await task(20); * ``` */ -export function workerTask(task:TaskAction):TaskContext{ +export function workerTask(task:TaskAction):TaskContext { const script = /*js*/` - globalThis.onmessage = async({data})=>{ - const {message, transfers} = await(${task.toString()})(data); + globalThis.onmessage = async ({data}) => { + const {message, transfers} = await (${task.toString()})(data); globalThis.postMessage(message, { transfer: transfers }); }; `; - return (message, transfers)=>{ - return new Promise((res, rej)=>{ + return (message, transfers) => { + return new Promise((res, rej) => { const worker = new Worker(`data:text/javascript;base64,${base64Encode(textEncode(script))}`, { type: "module" }); - worker.onmessage = ({data})=>{ + worker.onmessage = ({data}) => { res(data); worker.terminate(); }; - worker.onerror = (e)=>{ + worker.onerror = (e) => { rej(e); worker.terminate(); }; - worker.onmessageerror = (e)=>{ + worker.onmessageerror = (e) => { rej(e); worker.terminate(); }; diff --git a/src/pure_ext/csv.ts b/src/pure_ext/csv.ts index 09b19d1..f990467 100644 --- a/src/pure_ext/csv.ts +++ b/src/pure_ext/csv.ts @@ -12,7 +12,7 @@ import {primitiveParseX} from "../pure/primitive.ts"; * }]); * ``` */ -export function csvEncode>(data:T[], bom?:boolean):string{ +export function csvEncode>(data:T[], bom?:boolean):string { return stringify(data, { bom: bom, columns: Object.keys(data[0]) @@ -32,7 +32,7 @@ export function csvEncode>( * }); * ``` */ -export function csvDecode>(data:string, def:T):T[]{ +export function csvDecode>(data:string, def:T):T[] { const csv = parse(data, { skipFirstRow: true, trimLeadingSpace: true @@ -40,11 +40,11 @@ export function csvDecode>( const records:T[] = []; - for(const element of csv){ + for(const element of csv) { const props:Partial = {}; type K = keyof T; - for(const [k, v] of Object.entries(element)){ + for(const [k, v] of Object.entries(element)) { props[k] = primitiveParseX(v, def[k]); } diff --git a/src/pure_ext/sheet.ts b/src/pure_ext/sheet.ts index 6b1a584..a60238b 100644 --- a/src/pure_ext/sheet.ts +++ b/src/pure_ext/sheet.ts @@ -15,8 +15,8 @@ set_cptable(excelcp); * const enc = sheetEncodeRaw(book); * ``` */ -export function sheetEncodeRaw(book:RawWorkBook, cp?:number, pw?:string):Uint8Array{ - const buf = sheetWrite(book, { +export function sheetEncodeRaw(book:RawWorkBook, cp?:number, pw?:string):Uint8Array { + const buf:ArrayBuffer = sheetWrite(book, { type: "array", compression: true, cellStyles: true, @@ -37,16 +37,16 @@ export function sheetEncodeRaw(book:RawWorkBook, cp?:number, pw?:string):Uint8Ar * const enc = sheetEncode(book); * ``` */ -export function sheetEncode(sheets:Record, cp?:number, pw?:string):Uint8Array{ +export function sheetEncode(sheets:Record, cp?:number, pw?:string):Uint8Array { const book:Record = {}; - for(const [name, sheet] of Object.entries(sheets)){ + for(const [name, sheet] of Object.entries(sheets)) { const rows:RawWorkCell[][] = []; - for(const row of sheet){ + for(const row of sheet) { const columns:RawWorkCell[] = []; - for(const column of row){ + for(const column of row) { columns.push({ t: "s", v: column @@ -78,7 +78,7 @@ export function sheetEncode(sheets:Record, cp?:number, pw?:s * const enc = sheetEncodeRaw(book); * ``` */ -export function sheetDecodeRaw(data:Uint8Array, cp?:number, pw?:string):RawWorkBook{ +export function sheetDecodeRaw(data:Uint8Array, cp?:number, pw?:string):RawWorkBook { return sheetRead(data, { type: "array", dense: true, @@ -99,26 +99,24 @@ export function sheetDecodeRaw(data:Uint8Array, cp?:number, pw?:string):RawWorkB * const enc = sheetEncode(book); * ``` */ -export function sheetDecode(data:Uint8Array, cp?:number, pw?:string):Record{ +export function sheetDecode(data:Uint8Array, cp?:number, pw?:string):Record { const {Sheets} = sheetDecodeRaw(data, cp, pw); const book:Record = {}; - for(const [name, sheet] of Object.entries(Sheets)){ + for(const [name, sheet] of Object.entries(Sheets)) { const rows:string[][] = []; - for(const row of <(RawWorkCell[] | undefined)[]>sheet["!data"] ?? []){ + for(const row of <(RawWorkCell[] | undefined)[]>sheet["!data"] ?? []) { const columns:string[] = []; - for(const column of <(RawWorkCell | undefined)[]>row ?? []){ - if(!column || column.t === "e" || column.v === undefined){ + for(const column of <(RawWorkCell | undefined)[]>row ?? []) { + if(!column || column.t === "e" || column.v === undefined) { columns.push(""); - } - else if(column.v instanceof Date){ + } else if(column.v instanceof Date) { column.v.setMinutes(new Date().getTimezoneOffset()); columns.push(timeFormatSerialize(column.v, true)); - } - else{ + } else { columns.push(`${column.v}`); } } diff --git a/src/pure_ext/zip.ts b/src/pure_ext/zip.ts index 9ae5027..9da7378 100644 --- a/src/pure_ext/zip.ts +++ b/src/pure_ext/zip.ts @@ -14,13 +14,13 @@ import {type DataMap} from "../pure/minipack.ts"; * const files = await zipDecode(zip); * ``` */ -export async function zipEncode(files:DataMap[], pw?:string, weak?:boolean):Promise{ +export async function zipEncode(files:DataMap[], pw?:string, weak?:boolean):Promise { const zip = new ZipWriter(new Uint8ArrayWriter(), { password: pw, zipCrypto: weak }); - for(const {name, body} of files){ + for(const {name, body} of files) { await zip.add(name, new Uint8ArrayReader(body), { useWebWorkers: false }); @@ -42,7 +42,7 @@ export async function zipEncode(files:DataMap[], pw?:string, weak?:boolean):Prom * const files = await zipDecode(zip); * ``` */ -export async function zipDecode(archive:Uint8Array, pw?:string, encode?:string):Promise{ +export async function zipDecode(archive:Uint8Array, pw?:string, encode?:string):Promise { const files:DataMap[] = []; const zip = new ZipReader(new Uint8ArrayReader(archive), { useWebWorkers: false, @@ -50,8 +50,8 @@ export async function zipDecode(archive:Uint8Array, pw?:string, encode?:string): password: pw }); - for await(const entry of zip.getEntriesGenerator()){ - if(entry.directory){ + for await(const entry of zip.getEntriesGenerator()) { + if(entry.directory) { continue; } diff --git a/test/deno/json.test.ts b/test/deno/json.test.ts index a38bdd9..32a9a42 100644 --- a/test/deno/json.test.ts +++ b/test/deno/json.test.ts @@ -10,7 +10,7 @@ const object = { Deno.test({ name: "JSON: Read and Write", - async fn(){ + async fn() { const path = "./output.json"; await jsonWrite(path, object); @@ -22,7 +22,7 @@ Deno.test({ Deno.test({ name: "JSON: Load and Config", - async fn(){ + async fn() { const path = "./resource.json"; const result1 = await jsonLoad(path, object); diff --git a/test/deno/os.test.ts b/test/deno/os.test.ts deleted file mode 100644 index 96d7735..0000000 --- a/test/deno/os.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {assertEquals} from "../../deps.test.ts"; -import {osWindows, osMac, osLinux} from "../../src/deno/os.ts"; - -Deno.test({ - ignore: Deno.build.os !== "windows", - name: "OS: Windows", - fn(){ - assertEquals(osWindows, true); - assertEquals(osMac, false); - assertEquals(osLinux, false); - } -}); - -Deno.test({ - ignore: Deno.build.os !== "darwin", - name: "OS: Mac", - fn(){ - assertEquals(osWindows, false); - assertEquals(osMac, true); - assertEquals(osLinux, false); - } -}); - -Deno.test({ - ignore: Deno.build.os !== "linux", - name: "OS: Linux", - fn(){ - assertEquals(osWindows, false); - assertEquals(osMac, false); - assertEquals(osLinux, true); - } -}); \ No newline at end of file diff --git a/test/deno/path.test.ts b/test/deno/path.test.ts deleted file mode 100644 index 12c6892..0000000 --- a/test/deno/path.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import {assertEquals, dirname, fromFileUrl} from "../../deps.test.ts"; -import {pathSepL, pathSepW, pathTmp, pathVar, pathConfig, pathHome, pathMain} from "../../src/deno/path.ts"; - -const {HOME, USERPROFILE} = Deno.env.toObject(); -const ep = `${fromFileUrl(dirname(Deno.mainModule))}/`; - -Deno.test({ - name: "Path: Separator", - fn(){ - const sampleUnix = "C:/Windows/System32/cmd.exe"; - const sampleWindows = "C:\\Windows\\System32\\cmd.exe"; - - assertEquals(pathSepL(sampleWindows), sampleUnix); - assertEquals(pathSepW(sampleUnix), sampleWindows); - } -}); - -Deno.test({ - ignore: Deno.build.os !== "windows", - name: "Path: Windows", - fn(){ - assertEquals(pathTmp(), "C:/Windows/Temp"); - assertEquals(pathVar(), "C:/ProgramData"); - assertEquals(pathConfig(), `${pathSepL(USERPROFILE)}/AppData/Roaming`); - assertEquals(pathHome(), pathSepL(USERPROFILE)); - assertEquals(pathMain(), pathSepL(ep)); - } -}); - -Deno.test({ - ignore: Deno.build.os === "windows", - name: "Path: Unix", - fn(){ - assertEquals(pathTmp(), "/tmp"); - assertEquals(pathVar(), "/var"); - assertEquals(pathConfig(), `${HOME}/.config`); - assertEquals(pathHome(), HOME); - assertEquals(pathMain(), ep); - } -}); \ No newline at end of file diff --git a/test/deno/process.test.ts b/test/deno/process.test.ts index 0a51cba..da3b6f3 100644 --- a/test/deno/process.test.ts +++ b/test/deno/process.test.ts @@ -3,7 +3,7 @@ import {processRun} from "../../src/deno/process.ts"; Deno.test({ name: "Process: Run (no args)", - async fn(){ + async fn() { const result = await processRun("deno", "-V"); assertEquals(result, true); diff --git a/test/deno_ext/dom.test.ts b/test/deno_ext/dom.test.ts index ea30b1b..7d1426d 100644 --- a/test/deno_ext/dom.test.ts +++ b/test/deno_ext/dom.test.ts @@ -4,13 +4,13 @@ import {domDecode, domValuesPerId, domValueById, domElementsByName, domValuesByN const sample1 = ""; const sample2 = new DOMParser().parseFromString(sample1, "text/html")?.documentElement; -if(!sample2){ +if(!sample2) { throw new Error(); } Deno.test({ name: "DOM: Parse HTML", - fn(){ + fn() { const result = domDecode(sample1); assertEquals(result.innerHTML, sample2.innerHTML); @@ -19,7 +19,7 @@ Deno.test({ Deno.test({ name: "DOM: Collect input/textarea by ID", - fn(){ + fn() { const result = domValuesPerId(sample2); assertEquals(result.aaa, "123"); @@ -28,7 +28,7 @@ Deno.test({ Deno.test({ name: "DOM: Get value by ID", - fn(){ + fn() { const result = domValueById(sample2, "aaa"); assertEquals(result, "123"); @@ -37,7 +37,7 @@ Deno.test({ Deno.test({ name: "DOM: Get element by Name", - fn(){ + fn() { const result = domElementsByName(sample2, "aaa"); assertEquals(result.length, 2); @@ -46,7 +46,7 @@ Deno.test({ Deno.test({ name: "DOM: Get values by Name", - fn(){ + fn() { const result = domValuesByName(sample2, "aaa"); assertEquals(result, ["123", "456"]); @@ -55,7 +55,7 @@ Deno.test({ Deno.test({ name: "DOM: Get value by RadioActive", - fn(){ + fn() { const result = domValueByRadioActive(sample2, "aaa"); assertEquals(result, "123"); diff --git a/test/deno_ext/log.test.ts b/test/deno_ext/log.test.ts index 53e677b..b52959f 100644 --- a/test/deno_ext/log.test.ts +++ b/test/deno_ext/log.test.ts @@ -6,7 +6,7 @@ const path = `./${name}.log`; Deno.test({ name: "Log: Entry", - async fn(){ + async fn() { const log = logEntry(name, path); log.info("Lorem ipsum dolor sit amet."); diff --git a/test/deno_ext/smtp.test.ts b/test/deno_ext/smtp.test.ts index 0b40f93..a3a6fe9 100644 --- a/test/deno_ext/smtp.test.ts +++ b/test/deno_ext/smtp.test.ts @@ -10,10 +10,10 @@ const sample:MailMessage = { Deno.test({ name: "SMTP: Send", - async fn(){ + async fn() { const server = smtpTest(10025); - const result = new Promise((res)=>{ - server.bind((_, __, {headers, body})=>{ + const result = new Promise((res) => { + server.bind((_, __, {headers, body}) => { res({ from: headers.from, to: [headers.to], diff --git a/test/pure/base64.test.ts b/test/pure/base64.test.ts index 63a765f..2efd99d 100644 --- a/test/pure/base64.test.ts +++ b/test/pure/base64.test.ts @@ -12,7 +12,7 @@ const sample2 = "WA3HZCFCJ3Yupv6eWKOTmpoHV65OWy/Heu/Xr/UfKjo="; Deno.test({ name: "Base64: Encode", - fn(){ + fn() { const encode = base64Encode(sample1); assertEquals(encode, sample2); @@ -21,7 +21,7 @@ Deno.test({ Deno.test({ name: "Base64: Decode", - fn(){ + fn() { const decode = base64Decode(sample2); assertEquals(decode, sample1); diff --git a/test/pure/byte.test.ts b/test/pure/byte.test.ts index ca429e3..ef0251f 100644 --- a/test/pure/byte.test.ts +++ b/test/pure/byte.test.ts @@ -3,7 +3,7 @@ import {byteConcat} from "../../src/pure/byte.ts"; Deno.test({ name: "Byte: Concat", - fn(){ + fn() { const data = byteConcat(new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])); assertEquals(data, new Uint8Array([1, 2, 3, 4, 5, 6])); diff --git a/test/pure/crypto.test.ts b/test/pure/crypto.test.ts index e2cd6a9..f609fea 100644 --- a/test/pure/crypto.test.ts +++ b/test/pure/crypto.test.ts @@ -16,7 +16,7 @@ const hashResult = new Uint8Array([ Deno.test({ name: "Crypto: Random", - fn(){ + fn() { const {byteLength} = cryptoRandom(16); assertEquals(byteLength, 16); @@ -25,7 +25,7 @@ Deno.test({ Deno.test({ name: "Crypto: Hash", - async fn(){ + async fn() { const hash = await cryptoHash(sample, "SHA-512"); assertEquals(hash, hashResult); @@ -34,7 +34,7 @@ Deno.test({ Deno.test({ name: "Crypto: Encrypt and Decrypt", - async fn(){ + async fn() { const key1 = await cryptoGenerateEncryptKey(); const key2 = await cryptoGenerateEncryptKey(); @@ -47,7 +47,7 @@ Deno.test({ Deno.test({ name: "Crypto: Sign and Verify", - async fn(){ + async fn() { const {key, pub} = await cryptoGenerateSignKey(); const signature = await cryptoSign(sample, key); const verify = await cryptoVerify(sample, pub, signature); diff --git a/test/pure/deep.test.ts b/test/pure/deep.test.ts index 7c79877..f6af645 100644 --- a/test/pure/deep.test.ts +++ b/test/pure/deep.test.ts @@ -11,7 +11,7 @@ const sample = { Deno.test({ name: "Deep: Freeze", - fn(){ + fn() { const freeze = deepFreeze(structuredClone(sample)); const desc = Object.getOwnPropertyDescriptor(freeze.aaa.bbb, "ccc"); @@ -22,7 +22,7 @@ Deno.test({ Deno.test({ name: "Deep: Seal", - fn(){ + fn() { const seal = deepSeal(structuredClone(sample)); const desc = Object.getOwnPropertyDescriptor(seal.aaa.bbb, "ccc"); diff --git a/test/pure/deflate.test.ts b/test/pure/deflate.test.ts index ed5c386..d108441 100644 --- a/test/pure/deflate.test.ts +++ b/test/pure/deflate.test.ts @@ -10,7 +10,7 @@ const sample = new Uint8Array([ Deno.test({ name: "Deflate: Encode and Decode", - async fn(){ + async fn() { const encode = await deflateEncode(sample); const decode = await deflateDecode(encode); diff --git a/test/pure/fetch.test.ts b/test/pure/fetch.test.ts index 4d5990f..140f8db 100644 --- a/test/pure/fetch.test.ts +++ b/test/pure/fetch.test.ts @@ -10,7 +10,7 @@ const sample = new Uint8Array([ Deno.test({ name: "Fetch: Get", - async fn(){ + async fn() { const server = Deno.serve({ hostname: "127.0.0.1", port: 10080, diff --git a/test/pure/minipack.test.ts b/test/pure/minipack.test.ts index faab4e1..85fee1f 100644 --- a/test/pure/minipack.test.ts +++ b/test/pure/minipack.test.ts @@ -8,7 +8,7 @@ const samples = [{ Deno.test({ name: "Minipack: Encode and Decode", - fn(){ + fn() { const encode = minipackEncode(samples); const decode = minipackDecode(encode); diff --git a/test/pure/primitive.test.ts b/test/pure/primitive.test.ts index 2a3bcfd..26eadcb 100644 --- a/test/pure/primitive.test.ts +++ b/test/pure/primitive.test.ts @@ -3,7 +3,7 @@ import {primitiveParse, primitiveParseX} from "../../src/pure/primitive.ts"; Deno.test({ name: "Primitive: Parse", - fn(){ + fn() { const result1 = primitiveParse("foo", "string", true); const result2 = primitiveParse(null, "string"); const result3 = primitiveParse("12345", "number", true); @@ -22,7 +22,7 @@ Deno.test({ Deno.test({ name: "Primitive: ParseX", - fn(){ + fn() { const result1 = primitiveParseX("foo", ""); const result2 = primitiveParseX("123", 0); const result3 = primitiveParseX("true", false); diff --git a/test/pure/stream.test.ts b/test/pure/stream.test.ts index b263cdb..a8aa153 100644 --- a/test/pure/stream.test.ts +++ b/test/pure/stream.test.ts @@ -10,7 +10,7 @@ const sample = new Uint8Array([ Deno.test({ name: "Stream: Encode and Decode", - async fn(){ + async fn() { const encode = streamEncode(sample); const decode = await streamDecode(encode); diff --git a/test/pure/text.test.ts b/test/pure/text.test.ts index 3edd9d9..ade7944 100644 --- a/test/pure/text.test.ts +++ b/test/pure/text.test.ts @@ -12,7 +12,7 @@ const sampleBin = new Uint8Array([ Deno.test({ name: "Text: UTF-8 Encode and Decode", - fn(){ + fn() { const encode = textEncode(sampleText); const decode = textDecode(encode); @@ -22,7 +22,7 @@ Deno.test({ Deno.test({ name: "Text: HEX Encode and Decode", - fn(){ + fn() { const encode = textHexEncode(sampleBin); const decode = textHexDecode(encode); @@ -32,7 +32,7 @@ Deno.test({ Deno.test({ name: "Text: Trim", - fn(){ + fn() { const result = textPurgeSuperfluous(sampleText); assertEquals(result, "Lorem ipsum dolor sit amet."); @@ -41,7 +41,7 @@ Deno.test({ Deno.test({ name: "Text: Fix Width", - fn(){ + fn() { const result = textFixWidth("1+1=2"); assertEquals(result, "1+1=2"); @@ -50,7 +50,7 @@ Deno.test({ Deno.test({ name: "Text: Clean Up", - fn(){ + fn() { const result = textGetReady("1 + 1 = 2 "); assertEquals(result, "1 + 1 = 2"); @@ -59,7 +59,7 @@ Deno.test({ Deno.test({ name: "Text: Segment", - fn(){ + fn() { const {length} = textSplitBySegment("😄😁😆😅😂"); assertEquals(length, 5); @@ -68,7 +68,7 @@ Deno.test({ Deno.test({ name: "Text: Pad 0", - fn(){ + fn() { const pad = textPadZero(8); assertEquals(pad, "08"); diff --git a/test/pure/time.test.ts b/test/pure/time.test.ts index b46a802..ee2614d 100644 --- a/test/pure/time.test.ts +++ b/test/pure/time.test.ts @@ -5,7 +5,7 @@ const sample = new Date(2000, 0, 1, 0, 0, 0, 0); Deno.test({ name: "Time: Encode and Decode", - fn(){ + fn() { const encode = timeEncode(sample); const decode = timeDecode(encode); @@ -15,7 +15,7 @@ Deno.test({ Deno.test({ name: "Time: Delay", - async fn(){ + async fn() { await delay(100); assertEquals(true, true); @@ -24,7 +24,7 @@ Deno.test({ Deno.test({ name: "Time: Serial", - fn(){ + fn() { const result = timeFormatSerialize(sample); assertEquals(result, "20000101000000"); diff --git a/test/pure/worker.test.ts b/test/pure/worker.test.ts index a368912..bee16c9 100644 --- a/test/pure/worker.test.ts +++ b/test/pure/worker.test.ts @@ -6,8 +6,8 @@ const sample2 = new Uint8Array([2, 4, 6, 8]); Deno.test({ name: "Worker: Create Task.", - async fn(){ - const task = workerTask((v)=>{ + async fn() { + const task = workerTask((v) => { const result = v.map(n => n * 2); return { diff --git a/test/pure_ext/csv.test.ts b/test/pure_ext/csv.test.ts index ac8ae0a..b3a14a6 100644 --- a/test/pure_ext/csv.test.ts +++ b/test/pure_ext/csv.test.ts @@ -13,7 +13,7 @@ const sample = [{ Deno.test({ name: "CSV: Encode and Decode", - fn(){ + fn() { const encode = csvEncode(sample); const decode = csvDecode(encode, { foo: 0, diff --git a/test/pure_ext/sheet.test.ts b/test/pure_ext/sheet.test.ts index 0ddc1ab..ff653ec 100644 --- a/test/pure_ext/sheet.test.ts +++ b/test/pure_ext/sheet.test.ts @@ -30,7 +30,7 @@ const sample2:RawWorkBook = { Deno.test({ name: "EXCEL: Encode and Decode", - fn(){ + fn() { const encode = sheetEncode(sample1); const decode = sheetDecode(encode); @@ -40,7 +40,7 @@ Deno.test({ Deno.test({ name: "EXCEL: Raw Encode and Decode", - fn(){ + fn() { const encode = sheetEncodeRaw(sample2); const decode = sheetDecodeRaw(encode); diff --git a/test/pure_ext/zip.test.ts b/test/pure_ext/zip.test.ts index fe49197..c64d300 100644 --- a/test/pure_ext/zip.test.ts +++ b/test/pure_ext/zip.test.ts @@ -8,7 +8,7 @@ const sample = [{ Deno.test({ name: "ZIP: Encode and Decode", - async fn(){ + async fn() { const encode = await zipEncode(sample); const decode = await zipDecode(encode); From 126adf0cd39de7dbdd7b1f249fc7ade06c8573f4 Mon Sep 17 00:00:00 2001 From: dojyorin Date: Thu, 4 Jul 2024 22:53:06 +0900 Subject: [PATCH 5/5] code format. --- src/deno/json.ts | 6 +++--- src/deno/process.ts | 2 +- src/deno_ext/dom.ts | 20 ++++++++++---------- src/deno_ext/log.ts | 4 ++-- src/deno_ext/smtp.ts | 2 +- src/pure/base64.ts | 4 ++-- src/pure/byte.ts | 2 +- src/pure/crypto.ts | 24 ++++++++++++------------ src/pure/deep.ts | 6 +++--- src/pure/deflate.ts | 4 ++-- src/pure/fetch.ts | 2 +- src/pure/minipack.ts | 6 +++--- src/pure/primitive.ts | 6 +++--- src/pure/stream.ts | 4 ++-- src/pure/text.ts | 18 +++++++++--------- src/pure/time.ts | 10 +++++----- src/pure/worker.ts | 6 +++--- src/pure_ext/csv.ts | 8 ++++---- src/pure_ext/sheet.ts | 22 +++++++++++----------- src/pure_ext/zip.ts | 6 +++--- test/deno_ext/smtp.test.ts | 2 +- test/pure_ext/sheet.test.ts | 2 +- 22 files changed, 83 insertions(+), 83 deletions(-) diff --git a/src/deno/json.ts b/src/deno/json.ts index 4472b19..ab7bf27 100644 --- a/src/deno/json.ts +++ b/src/deno/json.ts @@ -7,7 +7,7 @@ import {type Opt} from "../pure/deep.ts"; * const json = await jsonRead("./data.json"); * ``` */ -export async function jsonRead>(path:string):Promise { +export async function jsonRead>(path: string): Promise { return JSON.parse(await Deno.readTextFile(path)); } @@ -20,7 +20,7 @@ export async function jsonRead>(path:string):Promise { * }); * ``` */ -export async function jsonWrite>(path:string, data:T):Promise { +export async function jsonWrite>(path: string, data: T): Promise { await Deno.writeTextFile(path, JSON.stringify(data, undefined, 4)); } @@ -34,7 +34,7 @@ export async function jsonWrite>(path:string, data:T):Promise>(path:string, def:T):Promise { +export async function jsonLoad>(path: string, def: T): Promise { try { return await jsonRead(path); } catch(e) { diff --git a/src/deno/process.ts b/src/deno/process.ts index 1fb3690..9681b89 100644 --- a/src/deno/process.ts +++ b/src/deno/process.ts @@ -5,7 +5,7 @@ * const success = await processRun("echo", "foobar"); * ``` */ -export async function processRun(...commands:string[]):Promise { +export async function processRun(...commands: string[]): Promise { const {success} = await new Deno.Command(commands.shift() ?? "", { args: commands, stdin: "null", diff --git a/src/deno_ext/dom.ts b/src/deno_ext/dom.ts index e27f2bf..cdeda71 100644 --- a/src/deno_ext/dom.ts +++ b/src/deno_ext/dom.ts @@ -1,14 +1,14 @@ import {type Element, DOMParser} from "../../deps.ts"; -function selectedElement(elements:Element[], attribute:"checked" | "selected") { +function selectedElement(elements: Element[], attribute: "checked" | "selected") { return elements.find(v => typeof v.getAttribute(attribute) === "string"); } -function getValue(element?:Element) { +function getValue(element?: Element) { return element?.getAttribute("value") ?? ""; } -function extractValue(element?:Element) { +function extractValue(element?: Element) { switch(element?.tagName) { case "SELECT": return getValue(selectedElement(element.getElementsByTagName("option"), "selected")); case "DATALIST": return getValue(selectedElement(element.getElementsByTagName("option"), "selected")); @@ -27,7 +27,7 @@ function extractValue(element?:Element) { * const dom = domDecode("
foo
"); * ``` */ -export function domDecode(html:string):Element { +export function domDecode(html: string): Element { const element = new DOMParser().parseFromString(html, "text/html")?.documentElement; if(!element) { @@ -45,8 +45,8 @@ export function domDecode(html:string):Element { * const result = domValuesPerId(dom); * ``` */ -export function domValuesPerId(element:Element):Record { - const records:Record = {}; +export function domValuesPerId(element: Element): Record { + const records: Record = {}; for(const input of element.getElementsByTagName("INPUT")) { if(!input.id) { @@ -76,7 +76,7 @@ export function domValuesPerId(element:Element):Record { * const result = domValueById(dom, "foo"); * ``` */ -export function domValueById(element:Element, id:string):string { +export function domValueById(element: Element, id: string): string { return extractValue(element.getElementById(id) ?? undefined); } @@ -88,7 +88,7 @@ export function domValueById(element:Element, id:string):string { * const result = domElementsByName(dom, "foo"); * ``` */ -export function domElementsByName(element:Element, name:string):Element[] { +export function domElementsByName(element: Element, name: string): Element[] { return element.getElementsByTagName("*").filter(v => v.getAttribute("name") === name); } @@ -101,7 +101,7 @@ export function domElementsByName(element:Element, name:string):Element[] { * const result = domValuesByName(dom, "foo"); * ``` */ -export function domValuesByName(element:Element, name:string):string[] { +export function domValuesByName(element: Element, name: string): string[] { return domElementsByName(element, name).map(v => extractValue(v)); } @@ -113,7 +113,7 @@ export function domValuesByName(element:Element, name:string):string[] { * const result = domValueByRadioActive(dom, "foo"); * ``` */ -export function domValueByRadioActive(element:Element, name:string):string { +export function domValueByRadioActive(element: Element, name: string): string { const elements = domElementsByName(element, name); if(elements.some(v => v.tagName !== "INPUT" || v.getAttribute("type") !== "radio")) { diff --git a/src/deno_ext/log.ts b/src/deno_ext/log.ts index 85d474d..46ef02a 100644 --- a/src/deno_ext/log.ts +++ b/src/deno_ext/log.ts @@ -1,6 +1,6 @@ import {Logger, ConsoleHandler, FileHandler, format} from "../../deps.ts"; -function logRecord(date:Date, level:string, message:string) { +function logRecord(date: Date, level: string, message: string) { return `${format(date, "yyyy-MM-ddTHH:mm:ss")} [${level}] ${message}`; } @@ -13,7 +13,7 @@ function logRecord(date:Date, level:string, message:string) { * const log = logEntry(); * ``` */ -export function logEntry(name?:string, path?:string):Logger { +export function logEntry(name?: string, path?: string): Logger { const level = "INFO"; const log = new Logger(name ?? "log", level, { diff --git a/src/deno_ext/smtp.ts b/src/deno_ext/smtp.ts index 0116d7f..a72e66c 100644 --- a/src/deno_ext/smtp.ts +++ b/src/deno_ext/smtp.ts @@ -27,7 +27,7 @@ export interface MailMessage { * }); * ``` */ -export async function smtpSend(path:string, message:MailMessage):Promise { +export async function smtpSend(path: string, message: MailMessage): Promise { const {protocol, hostname, port, username, password} = new URL(path); if(protocol !== "smtp:" && protocol !== "smtps:") { diff --git a/src/pure/base64.ts b/src/pure/base64.ts index c228141..b5192ab 100644 --- a/src/pure/base64.ts +++ b/src/pure/base64.ts @@ -7,7 +7,7 @@ * const decode = base64Decode(encode); * ``` */ -export function base64Encode(data:Uint8Array):string { +export function base64Encode(data: Uint8Array): string { return btoa(Array.from(data, v => String.fromCharCode(v)).join("")); } @@ -20,6 +20,6 @@ export function base64Encode(data:Uint8Array):string { * const decode = base64Decode(encode); * ``` */ -export function base64Decode(data:string):Uint8Array { +export function base64Decode(data: string): Uint8Array { return new Uint8Array(Array.from(atob(data), v => v.charCodeAt(0))); } \ No newline at end of file diff --git a/src/pure/byte.ts b/src/pure/byte.ts index 2826b1c..6e6f60f 100644 --- a/src/pure/byte.ts +++ b/src/pure/byte.ts @@ -5,7 +5,7 @@ * const byte = byteConcat(new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])); * ``` */ -export function byteConcat(...sources:BufferSource[]):Uint8Array { +export function byteConcat(...sources: BufferSource[]): Uint8Array { const output = new Uint8Array(sources.reduce((v, {byteLength}) => v + byteLength , 0)); let i = 0; diff --git a/src/pure/crypto.ts b/src/pure/crypto.ts index dfb8118..b9987cd 100644 --- a/src/pure/crypto.ts +++ b/src/pure/crypto.ts @@ -15,7 +15,7 @@ const CURVE_DSA = Object.freeze({ hash: "SHA-256" }); -async function generateKey(alg:EcKeyAlgorithm, usage:KeyUsage[]):Promise { +async function generateKey(alg: EcKeyAlgorithm, usage: KeyUsage[]): Promise { const {publicKey, privateKey} = await crypto.subtle.generateKey(alg, true, usage); return { @@ -24,7 +24,7 @@ async function generateKey(alg:EcKeyAlgorithm, usage:KeyUsage[]):Promise }; } -async function deriveKey(pub:Uint8Array, key:Uint8Array):Promise { +async function deriveKey(pub: Uint8Array, key: Uint8Array): Promise { return await crypto.subtle.deriveKey({ name: CURVE_KEX.name, public: await crypto.subtle.importKey("spki", pub, CURVE_KEX, false, []) @@ -41,7 +41,7 @@ async function deriveKey(pub:Uint8Array, key:Uint8Array):Promise { * const random = cryptoRandom(16); * ``` */ -export function cryptoRandom(n:number):Uint8Array { +export function cryptoRandom(n: number): Uint8Array { return crypto.getRandomValues(new Uint8Array(n)); } @@ -54,7 +54,7 @@ export function cryptoRandom(n:number):Uint8Array { * const hash = await cryptoHash(bin); * ``` */ -export async function cryptoHash(data:Uint8Array, alg?:string):Promise { +export async function cryptoHash(data: Uint8Array, alg?: string): Promise { return new Uint8Array(await crypto.subtle.digest(alg ?? "SHA-256", data)); } @@ -68,7 +68,7 @@ export async function cryptoHash(data:Uint8Array, alg?:string):Promise { +export async function cryptoGenerateEncryptKey(): Promise { return await generateKey(CURVE_KEX, ["deriveKey"]); } @@ -81,7 +81,7 @@ export async function cryptoGenerateEncryptKey():Promise { * const {pub, key} = await cryptoGenerateSignKey(); * ``` */ -export async function cryptoGenerateSignKey():Promise { +export async function cryptoGenerateSignKey(): Promise { return await generateKey(CURVE_DSA, ["sign", "verify"]); } @@ -98,8 +98,8 @@ export async function cryptoGenerateSignKey():Promise { * const decrypt = await cryptoDecrypt(encrypt, key2.pub, key1.key); * ``` */ -export async function cryptoEncrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Array):Promise { - const aes:AesGcmParams = { +export async function cryptoEncrypt(data: Uint8Array, pub: Uint8Array, key: Uint8Array): Promise { + const aes: AesGcmParams = { name: AES_MODE, iv: cryptoRandom(12) }; @@ -120,8 +120,8 @@ export async function cryptoEncrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Ar * const decrypt = await cryptoDecrypt(encrypt, key2.pub, key1.key); * ``` */ -export async function cryptoDecrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Array):Promise { - const aes:AesGcmParams = { +export async function cryptoDecrypt(data: Uint8Array, pub: Uint8Array, key: Uint8Array): Promise { + const aes: AesGcmParams = { name: AES_MODE, iv: data.subarray(0, 12) }; @@ -139,7 +139,7 @@ export async function cryptoDecrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Ar * const verify = await cryptoVerify(bin, pub, sign); * ``` */ -export async function cryptoSign(data:Uint8Array, key:Uint8Array):Promise { +export async function cryptoSign(data: Uint8Array, key: Uint8Array): Promise { return new Uint8Array(await crypto.subtle.sign(CURVE_DSA, await crypto.subtle.importKey("pkcs8", key, CURVE_DSA, false, ["sign"]), data)); } @@ -153,6 +153,6 @@ export async function cryptoSign(data:Uint8Array, key:Uint8Array):Promise { +export async function cryptoVerify(data: Uint8Array, pub: Uint8Array, sign: Uint8Array): Promise { return await crypto.subtle.verify(CURVE_DSA, await crypto.subtle.importKey("spki", pub, CURVE_DSA, false, ["verify"]), sign, data); } \ No newline at end of file diff --git a/src/pure/deep.ts b/src/pure/deep.ts index 66db8f6..21cbf4d 100644 --- a/src/pure/deep.ts +++ b/src/pure/deep.ts @@ -3,7 +3,7 @@ */ export type Opt = Partial>; -function hasObject(data:Record, key:string) { +function hasObject(data: Record, key: string) { return Object.hasOwn(data, key) && typeof data[key] === "object" && data[key] !== null; } @@ -18,7 +18,7 @@ function hasObject(data:Record, key:string) { * }); * ``` */ -export function deepFreeze>(data:T):Readonly { +export function deepFreeze>(data: T): Readonly { Object.freeze(data); for(const key in data) { @@ -41,7 +41,7 @@ export function deepFreeze>(data:T):Readonly { * }); * ``` */ -export function deepSeal>(data:T):T { +export function deepSeal>(data: T): T { Object.seal(data); for(const key in data) { diff --git a/src/pure/deflate.ts b/src/pure/deflate.ts index 3646bf5..a565b9f 100644 --- a/src/pure/deflate.ts +++ b/src/pure/deflate.ts @@ -12,7 +12,7 @@ const COMPRESS_CODEC = "deflate-raw"; * const decode = await deflateDecode(encode); * ``` */ -export async function deflateEncode(data:Uint8Array, codec?:string):Promise { +export async function deflateEncode(data: Uint8Array, codec?: string): Promise { return await streamDecode(streamEncode(data).pipeThrough(new CompressionStream(codec ?? COMPRESS_CODEC))); } @@ -26,6 +26,6 @@ export async function deflateEncode(data:Uint8Array, codec?:string):Promise { +export async function deflateDecode(data: Uint8Array, codec?: string): Promise { return await streamDecode(streamEncode(data).pipeThrough(new DecompressionStream(codec ?? COMPRESS_CODEC))); } \ No newline at end of file diff --git a/src/pure/fetch.ts b/src/pure/fetch.ts index 9c3c579..96ed9bf 100644 --- a/src/pure/fetch.ts +++ b/src/pure/fetch.ts @@ -29,7 +29,7 @@ export interface FetchInit extends Omit { * const response = await fetchExtend("./asset", "byte"); * ``` */ -export async function fetchExtend(path:string, type:T, option?:FetchInit):Promise { +export async function fetchExtend(path: string, type: T, option?: FetchInit): Promise { const u = new URL(path, globalThis?.location?.href); u.hash = ""; diff --git a/src/pure/minipack.ts b/src/pure/minipack.ts index e6c4db7..1b47c33 100644 --- a/src/pure/minipack.ts +++ b/src/pure/minipack.ts @@ -24,7 +24,7 @@ export interface DataMap { * const decode = minipackDecode(encode); * ``` */ -export function minipackEncode(files:DataMap[]):Uint8Array { +export function minipackEncode(files: DataMap[]): Uint8Array { const archive = new Uint8Array(files.reduce((size, {name, body}) => size + NAME_SIZE + BODY_SIZE + textEncode(name).byteLength + body.byteLength, 0)); let i = 0; @@ -60,8 +60,8 @@ export function minipackEncode(files:DataMap[]):Uint8Array { * const decode = minipackDecode(encode); * ``` */ -export function minipackDecode(archive:Uint8Array):DataMap[] { - const files:DataMap[] = []; +export function minipackDecode(archive: Uint8Array): DataMap[] { + const files: DataMap[] = []; for(let i = 0; i < archive.byteLength;) { const ns = new DataView(archive.buffer, i).getUint8(0); diff --git a/src/pure/primitive.ts b/src/pure/primitive.ts index 13fc5a5..d1dc99f 100644 --- a/src/pure/primitive.ts +++ b/src/pure/primitive.ts @@ -8,7 +8,7 @@ interface TypeMap { "boolean": boolean; } -function strictUndef(strict?:boolean) { +function strictUndef(strict?: boolean) { if(strict){ throw new Error(); } @@ -24,7 +24,7 @@ function strictUndef(strict?:boolean) { * const value = primitiveParse("123", "number", true); * ``` */ -export function primitiveParse(text:MaybeString, type:T, strict?:U):TypeStrict { +export function primitiveParse(text: MaybeString, type: T, strict?: U): TypeStrict { if(text === undefined || text === null) { return >strictUndef(strict); } @@ -46,7 +46,7 @@ export function primitiveParse(text: * const value = primitiveParseX("123", 0); * ``` */ -export function primitiveParseX(text:MaybeString, def:T):WidenLiteral { +export function primitiveParseX(text: MaybeString, def: T): WidenLiteral { if(text === undefined || text === null) { return >def; } diff --git a/src/pure/stream.ts b/src/pure/stream.ts index 6ec3421..4e26ea7 100644 --- a/src/pure/stream.ts +++ b/src/pure/stream.ts @@ -6,7 +6,7 @@ * const data = await streamDecode(stream); * ``` */ -export function streamEncode(...data:Uint8Array[]):ReadableStream { +export function streamEncode(...data: Uint8Array[]): ReadableStream { return new Blob(data).stream(); } @@ -18,6 +18,6 @@ export function streamEncode(...data:Uint8Array[]):ReadableStream { * const data = await streamDecode(stream); * ``` */ -export async function streamDecode(rs:ReadableStream):Promise { +export async function streamDecode(rs: ReadableStream): Promise { return new Uint8Array(await new Blob(await Array.fromAsync(rs)).arrayBuffer()); } \ No newline at end of file diff --git a/src/pure/text.ts b/src/pure/text.ts index f031b52..8fbd150 100644 --- a/src/pure/text.ts +++ b/src/pure/text.ts @@ -7,7 +7,7 @@ * const decode = textDecode(encode); * ``` */ -export function textEncode(data:string):Uint8Array { +export function textEncode(data: string): Uint8Array { return new TextEncoder().encode(data); } @@ -20,7 +20,7 @@ export function textEncode(data:string):Uint8Array { * const decode = textDecode(encode); * ``` */ -export function textDecode(data:Uint8Array, codec?:string):string { +export function textDecode(data: Uint8Array, codec?: string): string { return new TextDecoder(codec).decode(data); } @@ -33,7 +33,7 @@ export function textDecode(data:Uint8Array, codec?:string):string { * const decode = textHexDecode(encode); * ``` */ -export function textHexEncode(data:Uint8Array):string { +export function textHexEncode(data: Uint8Array): string { return Array.from(data, v => textPadZero(v, 2, 16)).join(""); } @@ -46,7 +46,7 @@ export function textHexEncode(data:Uint8Array):string { * const decode = textHexDecode(encode); * ``` */ -export function textHexDecode(data:string):Uint8Array { +export function textHexDecode(data: string): Uint8Array { return new Uint8Array(data.match(/[0-9a-fA-F]{2}/g)?.map(v => parseInt(v, 16)) ?? []); } @@ -57,7 +57,7 @@ export function textHexDecode(data:string):Uint8Array { * const format = textPurgeSuperfluous(" Lorem ipsum\r dolor sit \r\r amet. "); * ``` */ -export function textPurgeSuperfluous(data:string):string { +export function textPurgeSuperfluous(data: string): string { return data.trim().replace(/\r/g, "").replace(/ +/g, " ").replace(/\t+/g, "\t").replace(/\n+/g, "\n").replace(/^ /mg, "").replace(/ $/mg, ""); } @@ -68,7 +68,7 @@ export function textPurgeSuperfluous(data:string):string { * const format = textFixWidth("1+1=2"); * ``` */ -export function textFixWidth(data:string):string { +export function textFixWidth(data: string): string { return Object.entries({ "ヴ": "ヴ", "ガ": "ガ", "ギ": "ギ", "グ": "グ", "ゲ": "ゲ", "ゴ": "ゴ", @@ -107,7 +107,7 @@ export function textFixWidth(data:string):string { * const format = textGetReady("1 + 1 = 2 "); * ``` */ -export function textGetReady(data:string):string { +export function textGetReady(data: string): string { return textPurgeSuperfluous(textFixWidth(data)); } @@ -119,7 +119,7 @@ export function textGetReady(data:string):string { * const emojis = textSplitBySegment("😀😃😄😁😆😅😂🤣"); * ``` */ -export function textSplitBySegment(data:string):string[] { +export function textSplitBySegment(data: string): string[] { return Array.from(new Intl.Segmenter().segment(data), ({segment}) => segment); } @@ -131,6 +131,6 @@ export function textSplitBySegment(data:string):string[] { * const pad = textPadZero(8); * ``` */ -export function textPadZero(data:number, digit?:number, radix?:number):string { +export function textPadZero(data: number, digit?: number, radix?: number): string { return data.toString(radix).padStart(digit ?? 2, "0"); } \ No newline at end of file diff --git a/src/pure/time.ts b/src/pure/time.ts index 73caad3..4687b72 100644 --- a/src/pure/time.ts +++ b/src/pure/time.ts @@ -1,6 +1,6 @@ import {textPadZero} from "./text.ts"; -function dateFormat(date:string) { +function dateFormat(date: string) { const [y, m, d, h, mi, s] = date.split(/[/ :TZ_.-]/i).map(v => parseInt(v)); return new Date(y, (m ?? 1) - 1, d ?? 1, h ?? 0, mi ?? 0, s ?? 0); @@ -14,7 +14,7 @@ function dateFormat(date:string) { * await delay(1000); * ``` */ -export async function delay(time:number):Promise { +export async function delay(time: number): Promise { const t0 = performance.now(); await new Promise(done => setTimeout(done, time)); const t1 = performance.now(); @@ -32,7 +32,7 @@ export async function delay(time:number):Promise { * const date = timeDecode(time); * ``` */ -export function timeEncode(dt?:Date | string):number { +export function timeEncode(dt?: Date | string): number { return Math.floor((dt instanceof Date ? dt : typeof dt === "string" ? dateFormat(dt) : new Date()).getTime() / 1000); } @@ -46,7 +46,7 @@ export function timeEncode(dt?:Date | string):number { * const date = timeDecode(time); * ``` */ -export function timeDecode(dt?:number | string):Date { +export function timeDecode(dt?: number | string): Date { switch(typeof dt) { case "string": return dateFormat(dt); case "number": return new Date(dt * 1000); @@ -62,7 +62,7 @@ export function timeDecode(dt?:number | string):Date { * const format = timeFormatSerialize(); * ``` */ -export function timeFormatSerialize(dt?:Date | number | string, split?:boolean):string { +export function timeFormatSerialize(dt?: Date | number | string, split?: boolean): string { const ss = split ? "/" : ""; const sc = split ? ":" : ""; const date = dt instanceof Date ? dt : timeDecode(dt); diff --git a/src/pure/worker.ts b/src/pure/worker.ts index 76fc470..3185e54 100644 --- a/src/pure/worker.ts +++ b/src/pure/worker.ts @@ -9,12 +9,12 @@ interface TaskMessage { /** * Content of processing run by worker thread. */ -export type TaskAction = (message:T) => TaskMessage | Promise>; +export type TaskAction = (message: T) => TaskMessage | Promise>; /** * Run registered `TaskAction` in worker thread. */ -export type TaskContext = (message:T, transfers?:Transferable[]) => Promise; +export type TaskContext = (message: T, transfers?: Transferable[]) => Promise; /** * Register `TaskAction` and return reusable task execution context. @@ -33,7 +33,7 @@ export type TaskContext = (message:T, tran * const result2 = await task(20); * ``` */ -export function workerTask(task:TaskAction):TaskContext { +export function workerTask(task: TaskAction): TaskContext { const script = /*js*/` globalThis.onmessage = async ({data}) => { const {message, transfers} = await (${task.toString()})(data); diff --git a/src/pure_ext/csv.ts b/src/pure_ext/csv.ts index f990467..b409aef 100644 --- a/src/pure_ext/csv.ts +++ b/src/pure_ext/csv.ts @@ -12,7 +12,7 @@ import {primitiveParseX} from "../pure/primitive.ts"; * }]); * ``` */ -export function csvEncode>(data:T[], bom?:boolean):string { +export function csvEncode>(data: T[], bom?: boolean): string { return stringify(data, { bom: bom, columns: Object.keys(data[0]) @@ -32,16 +32,16 @@ export function csvEncode>( * }); * ``` */ -export function csvDecode>(data:string, def:T):T[] { +export function csvDecode>(data: string, def: T): T[] { const csv = parse(data, { skipFirstRow: true, trimLeadingSpace: true }); - const records:T[] = []; + const records: T[] = []; for(const element of csv) { - const props:Partial = {}; + const props: Partial = {}; type K = keyof T; for(const [k, v] of Object.entries(element)) { diff --git a/src/pure_ext/sheet.ts b/src/pure_ext/sheet.ts index a60238b..36a4372 100644 --- a/src/pure_ext/sheet.ts +++ b/src/pure_ext/sheet.ts @@ -15,8 +15,8 @@ set_cptable(excelcp); * const enc = sheetEncodeRaw(book); * ``` */ -export function sheetEncodeRaw(book:RawWorkBook, cp?:number, pw?:string):Uint8Array { - const buf:ArrayBuffer = sheetWrite(book, { +export function sheetEncodeRaw(book: RawWorkBook, cp?: number, pw?: string): Uint8Array { + const buf: ArrayBuffer = sheetWrite(book, { type: "array", compression: true, cellStyles: true, @@ -37,14 +37,14 @@ export function sheetEncodeRaw(book:RawWorkBook, cp?:number, pw?:string):Uint8Ar * const enc = sheetEncode(book); * ``` */ -export function sheetEncode(sheets:Record, cp?:number, pw?:string):Uint8Array { - const book:Record = {}; +export function sheetEncode(sheets: Record, cp?: number, pw?: string): Uint8Array { + const book: Record = {}; for(const [name, sheet] of Object.entries(sheets)) { - const rows:RawWorkCell[][] = []; + const rows: RawWorkCell[][] = []; for(const row of sheet) { - const columns:RawWorkCell[] = []; + const columns: RawWorkCell[] = []; for(const column of row) { columns.push({ @@ -78,7 +78,7 @@ export function sheetEncode(sheets:Record, cp?:number, pw?:s * const enc = sheetEncodeRaw(book); * ``` */ -export function sheetDecodeRaw(data:Uint8Array, cp?:number, pw?:string):RawWorkBook { +export function sheetDecodeRaw(data: Uint8Array, cp?: number, pw?: string): RawWorkBook { return sheetRead(data, { type: "array", dense: true, @@ -99,16 +99,16 @@ export function sheetDecodeRaw(data:Uint8Array, cp?:number, pw?:string):RawWorkB * const enc = sheetEncode(book); * ``` */ -export function sheetDecode(data:Uint8Array, cp?:number, pw?:string):Record { +export function sheetDecode(data: Uint8Array, cp?: number, pw?: string): Record { const {Sheets} = sheetDecodeRaw(data, cp, pw); - const book:Record = {}; + const book: Record = {}; for(const [name, sheet] of Object.entries(Sheets)) { - const rows:string[][] = []; + const rows: string[][] = []; for(const row of <(RawWorkCell[] | undefined)[]>sheet["!data"] ?? []) { - const columns:string[] = []; + const columns: string[] = []; for(const column of <(RawWorkCell | undefined)[]>row ?? []) { if(!column || column.t === "e" || column.v === undefined) { diff --git a/src/pure_ext/zip.ts b/src/pure_ext/zip.ts index 9da7378..25800a5 100644 --- a/src/pure_ext/zip.ts +++ b/src/pure_ext/zip.ts @@ -14,7 +14,7 @@ import {type DataMap} from "../pure/minipack.ts"; * const files = await zipDecode(zip); * ``` */ -export async function zipEncode(files:DataMap[], pw?:string, weak?:boolean):Promise { +export async function zipEncode(files: DataMap[], pw?: string, weak?: boolean): Promise { const zip = new ZipWriter(new Uint8ArrayWriter(), { password: pw, zipCrypto: weak @@ -42,8 +42,8 @@ export async function zipEncode(files:DataMap[], pw?:string, weak?:boolean):Prom * const files = await zipDecode(zip); * ``` */ -export async function zipDecode(archive:Uint8Array, pw?:string, encode?:string):Promise { - const files:DataMap[] = []; +export async function zipDecode(archive: Uint8Array, pw?: string, encode?: string): Promise { + const files: DataMap[] = []; const zip = new ZipReader(new Uint8ArrayReader(archive), { useWebWorkers: false, filenameEncoding: encode, diff --git a/test/deno_ext/smtp.test.ts b/test/deno_ext/smtp.test.ts index a3a6fe9..530bc26 100644 --- a/test/deno_ext/smtp.test.ts +++ b/test/deno_ext/smtp.test.ts @@ -1,7 +1,7 @@ import {assertEquals, delay, smtpTest} from "../../deps.test.ts"; import {type MailMessage, smtpSend} from "../../src/deno_ext/smtp.ts"; -const sample:MailMessage = { +const sample: MailMessage = { from: "from@example.com", to: ["to@example.com"], title: "Test title", diff --git a/test/pure_ext/sheet.test.ts b/test/pure_ext/sheet.test.ts index ff653ec..dd1046b 100644 --- a/test/pure_ext/sheet.test.ts +++ b/test/pure_ext/sheet.test.ts @@ -7,7 +7,7 @@ const sample1 = { ] }; -const sample2:RawWorkBook = { +const sample2: RawWorkBook = { SheetNames: ["test"], Sheets: { "test": {