/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/core-data/src/utils/get-normalized-comma-separable.js
20 строк
545 B
Andrew Duthie
Core Data: Implement `_fields` data reuse for entities (#19498)
24 авг 2020, 11:41
Не верифицирован
24 авг 2020, 11:41
bfbcc92
Код
Авторство
О чём код?
/** * Given a value which can be specified as one or the other of a comma-separated * string or an array, returns a value normalized to an array of strings, or * null if the value cannot be interpreted as either. * * @param {string|string[]|*} value * * @return {?(string[])} Normalized field value. */ function getNormalizedCommaSeparable( value ) { if ( typeof value === 'string' ) { return value.split( ',' ); } else if ( Array.isArray( value ) ) { return value; } return null; } export default getNormalizedCommaSeparable;