UNPKG

@aplus-frontend/ui

Version:

2 lines (1 loc) 379 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y={parentKey:"parentId",key:"id",children:"children"};function p(c,s={}){const t=Object.assign(s,y),i=t.parentKey,l=t.key,n=t.children,r=[];function o(a,d=null){for(const u of a){const e={...u};e[i]=d,r.push(e),e[n]?.length&&o(e[n],e[l]),delete e[n]}}return o(c,null),r}exports.toTreeArray=p;