(map, remaining, typeMapping, chunk)
| 936 | } |
| 937 | |
| 938 | #decodeMapAsMap(map, remaining, typeMapping, chunk) { |
| 939 | // using `remaining` instead of `length` & `map.size` to make it work even if the map contains duplicate keys |
| 940 | while (remaining > 0) { |
| 941 | if (this.#cursor >= chunk.length) { |
| 942 | return this.#decodeMapAsMap.bind( |
| 943 | this, |
| 944 | map, |
| 945 | remaining, |
| 946 | typeMapping |
| 947 | ); |
| 948 | } |
| 949 | |
| 950 | const key = this.#decodeMapKey(typeMapping, chunk); |
| 951 | if (typeof key === 'function') { |
| 952 | return this.#continueDecodeMapKey.bind( |
| 953 | this, |
| 954 | map, |
| 955 | remaining, |
| 956 | key, |
| 957 | typeMapping |
| 958 | ); |
| 959 | } |
| 960 | |
| 961 | if (this.#cursor >= chunk.length) { |
| 962 | return this.#continueDecodeMapValue.bind( |
| 963 | this, |
| 964 | map, |
| 965 | remaining, |
| 966 | key, |
| 967 | this.#decodeNestedType.bind(this, typeMapping), |
| 968 | typeMapping |
| 969 | ); |
| 970 | } |
| 971 | |
| 972 | const value = this.#decodeNestedType(typeMapping, chunk); |
| 973 | if (typeof value === 'function') { |
| 974 | return this.#continueDecodeMapValue.bind( |
| 975 | this, |
| 976 | map, |
| 977 | remaining, |
| 978 | key, |
| 979 | value, |
| 980 | typeMapping |
| 981 | ); |
| 982 | } |
| 983 | |
| 984 | map.set(key, value); |
| 985 | --remaining; |
| 986 | } |
| 987 | |
| 988 | return map; |
| 989 | } |
| 990 | |
| 991 | #decodeMapKey(typeMapping, chunk) { |
| 992 | const type = chunk[this.#cursor]; |
no test coverage detected