Skip to content

Commit cf40d83

Browse files
TypeScript: remove unused functions from Codecs.ts
1 parent a1beba7 commit cf40d83

File tree

1 file changed

+0
-77
lines changed
  • redistributable/TypeScript/morphir/internal

1 file changed

+0
-77
lines changed

redistributable/TypeScript/morphir/internal/Codecs.ts

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -83,55 +83,6 @@ export function decodeFloat(input: any): number {
8383
return input;
8484
}
8585

86-
export function decodeCustomType(decoderMap: CodecMap, input: any): object {
87-
if (typeof input == "string") input = [input];
88-
if (!(input instanceof Array)) {
89-
throw new DecodeError(`Expected Array, got ${typeof input}`);
90-
}
91-
if (!(typeof input[0] == "string")) {
92-
throw new DecodeError(`Expected String, got ${typeof input}`);
93-
}
94-
if (!decoderMap.has(input[0])) {
95-
let variantNames = Array.from(decoderMap.keys());
96-
let variantNameString = variantNames.join(", ");
97-
throw new DecodeError(
98-
`Expected one of "${variantNameString}", got ${input[0]}`
99-
);
100-
}
101-
return decoderMap.get(input[0])(input);
102-
}
103-
104-
export function decodeCustomTypeVariant(
105-
kind: string,
106-
argNames: Array<string>,
107-
argDecoders: CodecList,
108-
input: any
109-
): object {
110-
if (typeof input == "string") input = [input];
111-
112-
if (input[0] != kind) {
113-
throw new DecodeError(`Expected kind ${kind}, got ${input[0]}`);
114-
}
115-
116-
const argCount = input.length - 1;
117-
if (argCount != argDecoders.length) {
118-
throw new DecodeError(
119-
`Expected ${argDecoders.length} args for custom type "${kind}", got ${argCount}`
120-
);
121-
}
122-
123-
var result = {
124-
kind: kind,
125-
};
126-
127-
for (var i = 0; i < argDecoders.length; i++) {
128-
var paramName = argNames[i];
129-
result[paramName] = argDecoders[i](input[i + 1]);
130-
}
131-
132-
return result;
133-
}
134-
13586
export function decodeDict<K, V>(
13687
decodeKey: (any) => K,
13788
decodeValue: (any) => V,
@@ -240,34 +191,6 @@ export function encodeFloat(value: number): number {
240191
return value;
241192
}
242193

243-
export function encodeCustomType(encoderMap: CodecMap, value: any): any {
244-
if (encoderMap.has(value["kind"])) {
245-
const encoderFn: any = encoderMap.get(value["kind"]);
246-
return encoderFn(value);
247-
} else {
248-
throw new DecodeError(
249-
`Didn't find encoder for type variant: ${value["kind"]}`
250-
);
251-
}
252-
}
253-
254-
export function encodeCustomTypeVariant(
255-
argNames: Array<string>,
256-
argEncoders: CodecList,
257-
value: object
258-
): Array<any> {
259-
if (argNames.length == 0) {
260-
return value["kind"];
261-
} else {
262-
var result = [value["kind"]];
263-
for (var i = 0; i < argNames.length; i++) {
264-
const name = argNames[i];
265-
result.push(argEncoders[i](value[name]));
266-
}
267-
return result;
268-
}
269-
}
270-
271194
export function encodeDict<K, V>(
272195
encodeKey: (any) => K,
273196
encodeValue: (any) => V,

0 commit comments

Comments
 (0)