(self: Instruction)
| 881 | } |
| 882 | |
| 883 | const getMaxSizeInternal = (self: Instruction): number => { |
| 884 | switch (self._tag) { |
| 885 | case "Empty": { |
| 886 | return 0 |
| 887 | } |
| 888 | case "Single": { |
| 889 | return 1 |
| 890 | } |
| 891 | case "KeyValueMap": { |
| 892 | return Number.MAX_SAFE_INTEGER |
| 893 | } |
| 894 | case "Map": |
| 895 | case "WithDefault": |
| 896 | case "WithFallback": { |
| 897 | return getMaxSizeInternal(self.options as Instruction) |
| 898 | } |
| 899 | case "Both": { |
| 900 | const leftMaxSize = getMaxSizeInternal(self.left as Instruction) |
| 901 | const rightMaxSize = getMaxSizeInternal(self.right as Instruction) |
| 902 | return leftMaxSize + rightMaxSize |
| 903 | } |
| 904 | case "OrElse": { |
| 905 | const leftMin = getMaxSizeInternal(self.left as Instruction) |
| 906 | const rightMin = getMaxSizeInternal(self.right as Instruction) |
| 907 | return Math.min(leftMin, rightMin) |
| 908 | } |
| 909 | case "Variadic": { |
| 910 | const selfMaxSize = Option.getOrElse(self.max, () => Number.MAX_SAFE_INTEGER / 2) |
| 911 | const optionsMaxSize = getMaxSizeInternal(self.argumentOption as Instruction) |
| 912 | return Math.floor(selfMaxSize * optionsMaxSize) |
| 913 | } |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | const getUsageInternal = (self: Instruction): Usage.Usage => { |
| 918 | switch (self._tag) { |
no outgoing calls
no test coverage detected