mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-21 14:25:14 +00:00
Support units and percentages with whitespace separated and/or (possibly white-space surrounded) comma separated length lists.
15 lines
438 B
JavaScript
15 lines
438 B
JavaScript
const spaceReg = /\s+/;
|
|
const commaReg = /,/g;
|
|
|
|
export default function (lengthList) {
|
|
if (typeof lengthList === 'string') {
|
|
return lengthList.trim().replace(commaReg, ' ').split(spaceReg);
|
|
} else if (typeof lengthList === 'number') {
|
|
return [`${lengthList}`];
|
|
} else if (lengthList && typeof lengthList.map === 'function') {
|
|
return lengthList.map(d => `${d}`);
|
|
} else {
|
|
return [];
|
|
}
|
|
}
|