UNPKG

@opentiny/vue-renderless

Version:

An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.

23 lines (22 loc) 704 B
import "../../../chunk-G2ADBYYC.js"; import each from "../base/each"; import assign from "../object/assign"; const defaultOptions = { parentKey: "parentId", key: "id", children: "children" }; const unTreeList = (result, array, opts) => { let optChildren = opts.children; let optData = opts.data; each(array, (item) => { const children = item[optChildren]; if (optData) { item = item[optData]; } result.push(item); children && unTreeList(result, children, opts); }); return result; }; const toTreeArray = (array, options) => unTreeList([], array, assign({}, defaultOptions, options)); var toTreeArray_default = toTreeArray; export { toTreeArray_default as default };