Skip to content

Commit 126adf0

Browse files
committed
code format.
1 parent d3b2043 commit 126adf0

22 files changed

+83
-83
lines changed

src/deno/json.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {type Opt} from "../pure/deep.ts";
77
* const json = await jsonRead("./data.json");
88
* ```
99
*/
10-
export async function jsonRead<T extends Opt<T>>(path:string):Promise<T> {
10+
export async function jsonRead<T extends Opt<T>>(path: string): Promise<T> {
1111
return JSON.parse(await Deno.readTextFile(path));
1212
}
1313

@@ -20,7 +20,7 @@ export async function jsonRead<T extends Opt<T>>(path:string):Promise<T> {
2020
* });
2121
* ```
2222
*/
23-
export async function jsonWrite<T extends Opt<T>>(path:string, data:T):Promise<void> {
23+
export async function jsonWrite<T extends Opt<T>>(path: string, data: T): Promise<void> {
2424
await Deno.writeTextFile(path, JSON.stringify(data, undefined, 4));
2525
}
2626

@@ -34,7 +34,7 @@ export async function jsonWrite<T extends Opt<T>>(path:string, data:T):Promise<v
3434
* const json = await jsonLoad("./data.json", data);
3535
* ```
3636
*/
37-
export async function jsonLoad<T extends Opt<T>>(path:string, def:T):Promise<T> {
37+
export async function jsonLoad<T extends Opt<T>>(path: string, def: T): Promise<T> {
3838
try {
3939
return await jsonRead<T>(path);
4040
} catch(e) {

src/deno/process.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* const success = await processRun("echo", "foobar");
66
* ```
77
*/
8-
export async function processRun(...commands:string[]):Promise<boolean> {
8+
export async function processRun(...commands: string[]): Promise<boolean> {
99
const {success} = await new Deno.Command(commands.shift() ?? "", {
1010
args: commands,
1111
stdin: "null",

src/deno_ext/dom.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {type Element, DOMParser} from "../../deps.ts";
22

3-
function selectedElement(elements:Element[], attribute:"checked" | "selected") {
3+
function selectedElement(elements: Element[], attribute: "checked" | "selected") {
44
return elements.find(v => typeof v.getAttribute(attribute) === "string");
55
}
66

7-
function getValue(element?:Element) {
7+
function getValue(element?: Element) {
88
return element?.getAttribute("value") ?? "";
99
}
1010

11-
function extractValue(element?:Element) {
11+
function extractValue(element?: Element) {
1212
switch(element?.tagName) {
1313
case "SELECT": return getValue(selectedElement(element.getElementsByTagName("option"), "selected"));
1414
case "DATALIST": return getValue(selectedElement(element.getElementsByTagName("option"), "selected"));
@@ -27,7 +27,7 @@ function extractValue(element?:Element) {
2727
* const dom = domDecode("<div>foo</div>");
2828
* ```
2929
*/
30-
export function domDecode(html:string):Element {
30+
export function domDecode(html: string): Element {
3131
const element = new DOMParser().parseFromString(html, "text/html")?.documentElement;
3232

3333
if(!element) {
@@ -45,8 +45,8 @@ export function domDecode(html:string):Element {
4545
* const result = domValuesPerId(dom);
4646
* ```
4747
*/
48-
export function domValuesPerId(element:Element):Record<string, string> {
49-
const records:Record<string, string> = {};
48+
export function domValuesPerId(element: Element): Record<string, string> {
49+
const records: Record<string, string> = {};
5050

5151
for(const input of element.getElementsByTagName("INPUT")) {
5252
if(!input.id) {
@@ -76,7 +76,7 @@ export function domValuesPerId(element:Element):Record<string, string> {
7676
* const result = domValueById(dom, "foo");
7777
* ```
7878
*/
79-
export function domValueById(element:Element, id:string):string {
79+
export function domValueById(element: Element, id: string): string {
8080
return extractValue(element.getElementById(id) ?? undefined);
8181
}
8282

@@ -88,7 +88,7 @@ export function domValueById(element:Element, id:string):string {
8888
* const result = domElementsByName(dom, "foo");
8989
* ```
9090
*/
91-
export function domElementsByName(element:Element, name:string):Element[] {
91+
export function domElementsByName(element: Element, name: string): Element[] {
9292
return element.getElementsByTagName("*").filter(v => v.getAttribute("name") === name);
9393
}
9494

@@ -101,7 +101,7 @@ export function domElementsByName(element:Element, name:string):Element[] {
101101
* const result = domValuesByName(dom, "foo");
102102
* ```
103103
*/
104-
export function domValuesByName(element:Element, name:string):string[] {
104+
export function domValuesByName(element: Element, name: string): string[] {
105105
return domElementsByName(element, name).map(v => extractValue(v));
106106
}
107107

@@ -113,7 +113,7 @@ export function domValuesByName(element:Element, name:string):string[] {
113113
* const result = domValueByRadioActive(dom, "foo");
114114
* ```
115115
*/
116-
export function domValueByRadioActive(element:Element, name:string):string {
116+
export function domValueByRadioActive(element: Element, name: string): string {
117117
const elements = domElementsByName(element, name);
118118

119119
if(elements.some(v => v.tagName !== "INPUT" || v.getAttribute("type") !== "radio")) {

src/deno_ext/log.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Logger, ConsoleHandler, FileHandler, format} from "../../deps.ts";
22

3-
function logRecord(date:Date, level:string, message:string) {
3+
function logRecord(date: Date, level: string, message: string) {
44
return `${format(date, "yyyy-MM-ddTHH:mm:ss")} [${level}] ${message}`;
55
}
66

@@ -13,7 +13,7 @@ function logRecord(date:Date, level:string, message:string) {
1313
* const log = logEntry();
1414
* ```
1515
*/
16-
export function logEntry(name?:string, path?:string):Logger {
16+
export function logEntry(name?: string, path?: string): Logger {
1717
const level = "INFO";
1818

1919
const log = new Logger(name ?? "log", level, {

src/deno_ext/smtp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface MailMessage {
2727
* });
2828
* ```
2929
*/
30-
export async function smtpSend(path:string, message:MailMessage):Promise<void> {
30+
export async function smtpSend(path: string, message: MailMessage): Promise<void> {
3131
const {protocol, hostname, port, username, password} = new URL(path);
3232

3333
if(protocol !== "smtp:" && protocol !== "smtps:") {

src/pure/base64.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* const decode = base64Decode(encode);
88
* ```
99
*/
10-
export function base64Encode(data:Uint8Array):string {
10+
export function base64Encode(data: Uint8Array): string {
1111
return btoa(Array.from(data, v => String.fromCharCode(v)).join(""));
1212
}
1313

@@ -20,6 +20,6 @@ export function base64Encode(data:Uint8Array):string {
2020
* const decode = base64Decode(encode);
2121
* ```
2222
*/
23-
export function base64Decode(data:string):Uint8Array {
23+
export function base64Decode(data: string): Uint8Array {
2424
return new Uint8Array(Array.from(atob(data), v => v.charCodeAt(0)));
2525
}

src/pure/byte.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* const byte = byteConcat(new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]));
66
* ```
77
*/
8-
export function byteConcat(...sources:BufferSource[]):Uint8Array {
8+
export function byteConcat(...sources: BufferSource[]): Uint8Array {
99
const output = new Uint8Array(sources.reduce((v, {byteLength}) => v + byteLength , 0));
1010

1111
let i = 0;

src/pure/crypto.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const CURVE_DSA = Object.freeze<EcKeyAlgorithm & EcdsaParams>({
1515
hash: "SHA-256"
1616
});
1717

18-
async function generateKey(alg:EcKeyAlgorithm, usage:KeyUsage[]):Promise<PubKey> {
18+
async function generateKey(alg: EcKeyAlgorithm, usage: KeyUsage[]): Promise<PubKey> {
1919
const {publicKey, privateKey} = await crypto.subtle.generateKey(alg, true, usage);
2020

2121
return {
@@ -24,7 +24,7 @@ async function generateKey(alg:EcKeyAlgorithm, usage:KeyUsage[]):Promise<PubKey>
2424
};
2525
}
2626

27-
async function deriveKey(pub:Uint8Array, key:Uint8Array):Promise<CryptoKey> {
27+
async function deriveKey(pub: Uint8Array, key: Uint8Array): Promise<CryptoKey> {
2828
return await crypto.subtle.deriveKey({
2929
name: CURVE_KEX.name,
3030
public: await crypto.subtle.importKey("spki", pub, CURVE_KEX, false, [])
@@ -41,7 +41,7 @@ async function deriveKey(pub:Uint8Array, key:Uint8Array):Promise<CryptoKey> {
4141
* const random = cryptoRandom(16);
4242
* ```
4343
*/
44-
export function cryptoRandom(n:number):Uint8Array {
44+
export function cryptoRandom(n: number): Uint8Array {
4545
return crypto.getRandomValues(new Uint8Array(n));
4646
}
4747

@@ -54,7 +54,7 @@ export function cryptoRandom(n:number):Uint8Array {
5454
* const hash = await cryptoHash(bin);
5555
* ```
5656
*/
57-
export async function cryptoHash(data:Uint8Array, alg?:string):Promise<Uint8Array> {
57+
export async function cryptoHash(data: Uint8Array, alg?: string): Promise<Uint8Array> {
5858
return new Uint8Array(await crypto.subtle.digest(alg ?? "SHA-256", data));
5959
}
6060

@@ -68,7 +68,7 @@ export async function cryptoHash(data:Uint8Array, alg?:string):Promise<Uint8Arra
6868
* const key2 = await cryptoGenerateEncryptKey();
6969
* ```
7070
*/
71-
export async function cryptoGenerateEncryptKey():Promise<PubKey> {
71+
export async function cryptoGenerateEncryptKey(): Promise<PubKey> {
7272
return await generateKey(CURVE_KEX, ["deriveKey"]);
7373
}
7474

@@ -81,7 +81,7 @@ export async function cryptoGenerateEncryptKey():Promise<PubKey> {
8181
* const {pub, key} = await cryptoGenerateSignKey();
8282
* ```
8383
*/
84-
export async function cryptoGenerateSignKey():Promise<PubKey> {
84+
export async function cryptoGenerateSignKey(): Promise<PubKey> {
8585
return await generateKey(CURVE_DSA, ["sign", "verify"]);
8686
}
8787

@@ -98,8 +98,8 @@ export async function cryptoGenerateSignKey():Promise<PubKey> {
9898
* const decrypt = await cryptoDecrypt(encrypt, key2.pub, key1.key);
9999
* ```
100100
*/
101-
export async function cryptoEncrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Array):Promise<Uint8Array> {
102-
const aes:AesGcmParams = {
101+
export async function cryptoEncrypt(data: Uint8Array, pub: Uint8Array, key: Uint8Array): Promise<Uint8Array> {
102+
const aes: AesGcmParams = {
103103
name: AES_MODE,
104104
iv: cryptoRandom(12)
105105
};
@@ -120,8 +120,8 @@ export async function cryptoEncrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Ar
120120
* const decrypt = await cryptoDecrypt(encrypt, key2.pub, key1.key);
121121
* ```
122122
*/
123-
export async function cryptoDecrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Array):Promise<Uint8Array> {
124-
const aes:AesGcmParams = {
123+
export async function cryptoDecrypt(data: Uint8Array, pub: Uint8Array, key: Uint8Array): Promise<Uint8Array> {
124+
const aes: AesGcmParams = {
125125
name: AES_MODE,
126126
iv: data.subarray(0, 12)
127127
};
@@ -139,7 +139,7 @@ export async function cryptoDecrypt(data:Uint8Array, pub:Uint8Array, key:Uint8Ar
139139
* const verify = await cryptoVerify(bin, pub, sign);
140140
* ```
141141
*/
142-
export async function cryptoSign(data:Uint8Array, key:Uint8Array):Promise<Uint8Array> {
142+
export async function cryptoSign(data: Uint8Array, key: Uint8Array): Promise<Uint8Array> {
143143
return new Uint8Array(await crypto.subtle.sign(CURVE_DSA, await crypto.subtle.importKey("pkcs8", key, CURVE_DSA, false, ["sign"]), data));
144144
}
145145

@@ -153,6 +153,6 @@ export async function cryptoSign(data:Uint8Array, key:Uint8Array):Promise<Uint8A
153153
* const verify = await cryptoVerify(bin, pub, sign);
154154
* ```
155155
*/
156-
export async function cryptoVerify(data:Uint8Array, pub:Uint8Array, sign:Uint8Array):Promise<boolean> {
156+
export async function cryptoVerify(data: Uint8Array, pub: Uint8Array, sign: Uint8Array): Promise<boolean> {
157157
return await crypto.subtle.verify(CURVE_DSA, await crypto.subtle.importKey("spki", pub, CURVE_DSA, false, ["verify"]), sign, data);
158158
}

src/pure/deep.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
export type Opt<T> = Partial<Record<keyof T, unknown>>;
55

6-
function hasObject(data:Record<string | number | symbol, unknown>, key:string) {
6+
function hasObject(data: Record<string | number | symbol, unknown>, key: string) {
77
return Object.hasOwn(data, key) && typeof data[key] === "object" && data[key] !== null;
88
}
99

@@ -18,7 +18,7 @@ function hasObject(data:Record<string | number | symbol, unknown>, key:string) {
1818
* });
1919
* ```
2020
*/
21-
export function deepFreeze<T extends Opt<T>>(data:T):Readonly<T> {
21+
export function deepFreeze<T extends Opt<T>>(data: T): Readonly<T> {
2222
Object.freeze(data);
2323

2424
for(const key in data) {
@@ -41,7 +41,7 @@ export function deepFreeze<T extends Opt<T>>(data:T):Readonly<T> {
4141
* });
4242
* ```
4343
*/
44-
export function deepSeal<T extends Opt<T>>(data:T):T {
44+
export function deepSeal<T extends Opt<T>>(data: T): T {
4545
Object.seal(data);
4646

4747
for(const key in data) {

src/pure/deflate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const COMPRESS_CODEC = "deflate-raw";
1212
* const decode = await deflateDecode(encode);
1313
* ```
1414
*/
15-
export async function deflateEncode(data:Uint8Array, codec?:string):Promise<Uint8Array> {
15+
export async function deflateEncode(data: Uint8Array, codec?: string): Promise<Uint8Array> {
1616
return await streamDecode(streamEncode(data).pipeThrough(new CompressionStream(codec ?? COMPRESS_CODEC)));
1717
}
1818

@@ -26,6 +26,6 @@ export async function deflateEncode(data:Uint8Array, codec?:string):Promise<Uint
2626
* const decode = await deflateDecode(encode);
2727
* ```
2828
*/
29-
export async function deflateDecode(data:Uint8Array, codec?:string):Promise<Uint8Array> {
29+
export async function deflateDecode(data: Uint8Array, codec?: string): Promise<Uint8Array> {
3030
return await streamDecode(streamEncode(data).pipeThrough(new DecompressionStream(codec ?? COMPRESS_CODEC)));
3131
}

src/pure/fetch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface FetchInit extends Omit<RequestInit, "integrity" | "window"> {
2929
* const response = await fetchExtend("./asset", "byte");
3030
* ```
3131
*/
32-
export async function fetchExtend<T extends keyof ResponseType>(path:string, type:T, option?:FetchInit):Promise<ResponseType[T]> {
32+
export async function fetchExtend<T extends keyof ResponseType>(path: string, type: T, option?: FetchInit): Promise<ResponseType[T]> {
3333
const u = new URL(path, globalThis?.location?.href);
3434
u.hash = "";
3535

src/pure/minipack.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface DataMap {
2424
* const decode = minipackDecode(encode);
2525
* ```
2626
*/
27-
export function minipackEncode(files:DataMap[]):Uint8Array {
27+
export function minipackEncode(files: DataMap[]): Uint8Array {
2828
const archive = new Uint8Array(files.reduce((size, {name, body}) => size + NAME_SIZE + BODY_SIZE + textEncode(name).byteLength + body.byteLength, 0));
2929

3030
let i = 0;
@@ -60,8 +60,8 @@ export function minipackEncode(files:DataMap[]):Uint8Array {
6060
* const decode = minipackDecode(encode);
6161
* ```
6262
*/
63-
export function minipackDecode(archive:Uint8Array):DataMap[] {
64-
const files:DataMap[] = [];
63+
export function minipackDecode(archive: Uint8Array): DataMap[] {
64+
const files: DataMap[] = [];
6565

6666
for(let i = 0; i < archive.byteLength;) {
6767
const ns = new DataView(archive.buffer, i).getUint8(0);

src/pure/primitive.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface TypeMap {
88
"boolean": boolean;
99
}
1010

11-
function strictUndef(strict?:boolean) {
11+
function strictUndef(strict?: boolean) {
1212
if(strict){
1313
throw new Error();
1414
}
@@ -24,7 +24,7 @@ function strictUndef(strict?:boolean) {
2424
* const value = primitiveParse("123", "number", true);
2525
* ```
2626
*/
27-
export function primitiveParse<T extends keyof TypeMap, U extends boolean>(text:MaybeString, type:T, strict?:U):TypeStrict<TypeMap[T], U> {
27+
export function primitiveParse<T extends keyof TypeMap, U extends boolean>(text: MaybeString, type: T, strict?: U): TypeStrict<TypeMap[T], U> {
2828
if(text === undefined || text === null) {
2929
return <TypeStrict<TypeMap[T], U>>strictUndef(strict);
3030
}
@@ -46,7 +46,7 @@ export function primitiveParse<T extends keyof TypeMap, U extends boolean>(text:
4646
* const value = primitiveParseX("123", 0);
4747
* ```
4848
*/
49-
export function primitiveParseX<T extends string | number | boolean>(text:MaybeString, def:T):WidenLiteral<T> {
49+
export function primitiveParseX<T extends string | number | boolean>(text: MaybeString, def: T): WidenLiteral<T> {
5050
if(text === undefined || text === null) {
5151
return <WidenLiteral<T>>def;
5252
}

src/pure/stream.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* const data = await streamDecode(stream);
77
* ```
88
*/
9-
export function streamEncode(...data:Uint8Array[]):ReadableStream<Uint8Array> {
9+
export function streamEncode(...data: Uint8Array[]): ReadableStream<Uint8Array> {
1010
return new Blob(data).stream();
1111
}
1212

@@ -18,6 +18,6 @@ export function streamEncode(...data:Uint8Array[]):ReadableStream<Uint8Array> {
1818
* const data = await streamDecode(stream);
1919
* ```
2020
*/
21-
export async function streamDecode(rs:ReadableStream<Uint8Array>):Promise<Uint8Array> {
21+
export async function streamDecode(rs: ReadableStream<Uint8Array>): Promise<Uint8Array> {
2222
return new Uint8Array(await new Blob(await Array.fromAsync(rs)).arrayBuffer());
2323
}

0 commit comments

Comments
 (0)