From aaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 30 Mar 2020 16:09:32 +0530 Subject: re-format with prettier v2, fix HTML --- src/util/codec.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/util/codec.ts') diff --git a/src/util/codec.ts b/src/util/codec.ts index 09fa9f953..a8f495238 100644 --- a/src/util/codec.ts +++ b/src/util/codec.ts @@ -110,7 +110,8 @@ class ObjectCodecBuilder { throw new DecodingError( `expected object for ${objectDisplayName} at ${renderContext( c, - )} but got ${typeof x}`) + )} but got ${typeof x}`, + ); } const obj: any = {}; for (const prop of propList) { @@ -273,7 +274,9 @@ export const codecForNumber: Codec = { if (typeof x === "number") { return x; } - throw new DecodingError(`expected number at ${renderContext(c)} but got ${typeof x}`); + throw new DecodingError( + `expected number at ${renderContext(c)} but got ${typeof x}`, + ); }, }; @@ -285,7 +288,9 @@ export const codecForBoolean: Codec = { if (typeof x === "boolean") { return x; } - throw new DecodingError(`expected boolean at ${renderContext(c)} but got ${typeof x}`); + throw new DecodingError( + `expected boolean at ${renderContext(c)} but got ${typeof x}`, + ); }, }; @@ -297,7 +302,9 @@ export const codecForString: Codec = { if (typeof x === "string") { return x; } - throw new DecodingError(`expected string at ${renderContext(c)} but got ${typeof x}`); + throw new DecodingError( + `expected string at ${renderContext(c)} but got ${typeof x}`, + ); }, }; @@ -320,21 +327,25 @@ export function makeCodecForConstString(s: V): Codec { return x; } throw new DecodingError( - `expected string constant "${s}" at ${renderContext(c)} but got ${typeof x}`, + `expected string constant "${s}" at ${renderContext( + c, + )} but got ${typeof x}`, ); }, }; } -export function makeCodecOptional(innerCodec: Codec): Codec { +export function makeCodecOptional( + innerCodec: Codec, +): Codec { return { decode(x: any, c?: Context): V | undefined { if (x === undefined || x === null) { return undefined; } return innerCodec.decode(x, c); - } - } + }, + }; } export function typecheckedCodec(c: Codec): Codec { -- cgit v1.2.3