summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/util/codec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/util/codec.ts')
-rw-r--r--packages/taler-wallet-core/src/util/codec.ts20
1 files changed, 11 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/util/codec.ts b/packages/taler-wallet-core/src/util/codec.ts
index 111abc38c..741a5b172 100644
--- a/packages/taler-wallet-core/src/util/codec.ts
+++ b/packages/taler-wallet-core/src/util/codec.ts
@@ -292,15 +292,17 @@ export function codecForNumber(): Codec<number> {
/**
* Return a codec for a value that must be a number.
*/
-export const codecForBoolean: Codec<boolean> = {
- decode(x: any, c?: Context): boolean {
- if (typeof x === "boolean") {
- return x;
- }
- throw new DecodingError(
- `expected boolean at ${renderContext(c)} but got ${typeof x}`,
- );
- },
+export function codecForBoolean(): Codec<boolean> {
+ return {
+ decode(x: any, c?: Context): boolean {
+ if (typeof x === "boolean") {
+ return x;
+ }
+ throw new DecodingError(
+ `expected boolean at ${renderContext(c)} but got ${typeof x}`,
+ );
+ },
+ }
};
/**