diff --git a/src/react/ReactChildren.js b/src/react/ReactChildren.js index bbc07d81edaad3705a3dca0942e1cbc01bff2624..4e7b1fee02b4aa8eb16bf89097523ff44cb82240 100644 --- a/src/react/ReactChildren.js +++ b/src/react/ReactChildren.js @@ -3,6 +3,22 @@ function mapChildren(children, func, context) { return children; } +function map(children, func, context) { + let arr = [] + if (!Array.isArray(children)) { + return func(children,0) + } + children.map((item, index) => { + if (Array.isArray(item)) { + arr.push(...item.map(subItem => func(subItem, index))) + } else { + arr.push(func(item,index)) + } + }) + return arr + +} + export { mapChildren as map, }; \ No newline at end of file