aboutsummaryrefslogtreecommitdiff
path: root/src/util/codec.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-03-30 16:09:32 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-03-30 16:09:32 +0530
commitaaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf (patch)
tree9274139660f30c4857d80044eb4ac283aac1775a /src/util/codec.ts
parent15e18440dbad55df19977a2eb7053681259afc18 (diff)
downloadwallet-core-aaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf.tar.xz
re-format with prettier v2, fix HTML
Diffstat (limited to 'src/util/codec.ts')
-rw-r--r--src/util/codec.ts27
1 files changed, 19 insertions, 8 deletions
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<OutputType, PartialOutputType> {
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<number> = {
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<boolean> = {
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<string> = {
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<V extends string>(s: V): Codec<V> {
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<V>(innerCodec: Codec<V>): Codec<V | undefined> {
+export function makeCodecOptional<V>(
+ innerCodec: Codec<V>,
+): Codec<V | undefined> {
return {
decode(x: any, c?: Context): V | undefined {
if (x === undefined || x === null) {
return undefined;
}
return innerCodec.decode(x, c);
- }
- }
+ },
+ };
}
export function typecheckedCodec<T = undefined>(c: Codec<T>): Codec<T> {