Skip to content

Instantly share code, notes, and snippets.

View JZLeung's full-sized avatar

Leung-JZ JZLeung

View GitHub Profile
export const walkAndDealItems = (datas, func, key = 'children') => {
if (!func || typeof func !== 'function') return datas
const nodes = [...datas]
let node = nodes.shift()
while (node) {
func(node)
if (node[key]) {
for (const cNode of node[key]) {
nodes.push(cNode)
}