MultiMap handles string values a bit better now

This commit is contained in:
Kir_Antipov 2024-01-04 10:12:29 +00:00
parent d62de05339
commit cf2e81d32f

View file

@ -330,7 +330,7 @@ export class MultiMap<K, V> extends ArrayMap<K, V[]> {
* @returns This {@link MultiMap} instance for chaining purposes.
*/
set(key: K, value: V | Iterable<V>): this {
const values = isIterable(value) ? asArray(value) : [value];
const values = typeof value !== "string" && isIterable(value) ? asArray(value) : [value];
return super.set(key, values);
}
@ -368,7 +368,7 @@ export class MultiMap<K, V> extends ArrayMap<K, V[]> {
return this.set(key, value as V);
}
if (isIterable(value)) {
if (typeof value !== "string" && isIterable(value)) {
existingValues.push(...value);
} else {
existingValues.push(value);