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": {