/
githubmirror
/
react-native
Обзор
Документация
Войти
/
githubmirror
/
react-native
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/community-cli-plugin/src/utils/parseKeyValueParamArray.js
30 строк
825 B
Marco Wang
Transform $ReadOnlyArray to ReadonlyArray 17/n (#55109)
14 янв 2026, 07:33
14 янв 2026, 07:33
7051a07
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict-local * @format */ export default function parseKeyValueParamArray( keyValueArray: ReadonlyArray<string>, ): Record<string, string> { const result = {}; for (const item of keyValueArray) { if (item.indexOf('=') === -1) { throw new Error('Expected parameter to include "=" but found: ' + item); } if (item.indexOf('&') !== -1) { throw new Error('Parameter cannot include "&" but found: ' + item); } const params = new URLSearchParams(item); params.forEach((value, key) => { // $FlowExpectedError[prop-missing] result[key] = value; }); } return result; }