/
githubmirror
/
wp-calypso
Обзор
Документация
Войти
/
githubmirror
/
wp-calypso
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/js-utils/src/map-values.ts
18 строк
551 B
Griffith Chen
Remove lodash mapValues, pickBy, and omitBy in favor of @automattic/js-utils (#111739)
17 июн 2026, 08:32
Не верифицирован
17 июн 2026, 08:32
9ee3ece
Код
Авторство
О чём код?
/** * Returns a new object with the same own enumerable string keys as `object`, * each value replaced by `iteratee( value, key, object )`. */ function mapValues< T, R >( object: Record< string, T > | null | undefined, iteratee: ( value: T, key: string, object: Record< string, T > ) => R ): Record< string, R > { const source: Record< string, T > = object ?? {}; return Object.fromEntries( Object.entries( source ).map( ( [ key, value ] ): [ string, R ] => [ key, iteratee( value, key, source ), ] ) ); } export default mapValues;