( value: CollectionIndexSerializableValue, )
| 129 | } |
| 130 | |
| 131 | function stableStringifyCollectionIndexValue( |
| 132 | value: CollectionIndexSerializableValue, |
| 133 | ): string { |
| 134 | if (value === null) { |
| 135 | return `null` |
| 136 | } |
| 137 | |
| 138 | if (Array.isArray(value)) { |
| 139 | return `[${value.map(stableStringifyCollectionIndexValue).join(`,`)}]` |
| 140 | } |
| 141 | |
| 142 | if (typeof value !== `object`) { |
| 143 | return JSON.stringify(value) |
| 144 | } |
| 145 | |
| 146 | const sortedKeys = Object.keys(value).sort((left, right) => |
| 147 | compareStringsCodePoint(left, right), |
| 148 | ) |
| 149 | const serializedEntries = sortedKeys.map( |
| 150 | (key) => |
| 151 | `${JSON.stringify(key)}:${stableStringifyCollectionIndexValue(value[key]!)}`, |
| 152 | ) |
| 153 | return `{${serializedEntries.join(`,`)}}` |
| 154 | } |
| 155 | |
| 156 | function createCollectionIndexMetadata<TKey extends string | number>( |
| 157 | indexId: number, |
no test coverage detected