@okutils/array-to-tree 0.0.2 → 0.0.3-a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/README.zh-CN.md +7 -7
- package/dist/cjs/{index.js → index.cjs} +1 -1
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/{index.js → index.mjs} +1 -1
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -111,13 +111,13 @@ export interface ArrayToTreeOptions {
|
|
|
111
111
|
}
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
| Option | Type | Default | Description
|
|
115
|
-
| ------------------- | --------- | ------------------------------------- |
|
|
116
|
-
| `customId` | `string` | `'id'` | Specifies the field name for the unique identifier of a node.
|
|
117
|
-
| `parentId` | `string` | `'parentId'` | Specifies the field name for associating with the parent node.
|
|
118
|
-
| `childrenId` | `string` | `'children'` | Specifies the field name for the array of child nodes in the generated tree.
|
|
119
|
-
| `allowSelfAsParent` | `boolean` | `false` | Whether to allow a node's `parentId` to be equal to its own `id`.
|
|
120
|
-
| `rootId` | `string` | `'__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__'` | An internal virtual root ID, which usually does not need to be changed. The `parentId` of root nodes should be `null` or `
|
|
114
|
+
| Option | Type | Default | Description |
|
|
115
|
+
| ------------------- | --------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
116
|
+
| `customId` | `string` | `'id'` | Specifies the field name for the unique identifier of a node. |
|
|
117
|
+
| `parentId` | `string` | `'parentId'` | Specifies the field name for associating with the parent node. |
|
|
118
|
+
| `childrenId` | `string` | `'children'` | Specifies the field name for the array of child nodes in the generated tree. |
|
|
119
|
+
| `allowSelfAsParent` | `boolean` | `false` | Whether to allow a node's `parentId` to be equal to its own `id`. |
|
|
120
|
+
| `rootId` | `string` | `'__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__'` | An internal virtual root ID, which usually does not need to be changed. The `parentId` of root nodes should be `null`, `undefined`, or an empty string `""`. |
|
|
121
121
|
|
|
122
122
|
#### Example: Using Custom Fields
|
|
123
123
|
|
package/README.zh-CN.md
CHANGED
|
@@ -111,13 +111,13 @@ export interface ArrayToTreeOptions {
|
|
|
111
111
|
}
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
| 选项 | 类型 | 默认值 | 描述
|
|
115
|
-
| ------------------- | --------- | ------------------------------------- |
|
|
116
|
-
| `customId` | `string` | `'id'` | 指定节点唯一标识的字段名。
|
|
117
|
-
| `parentId` | `string` | `'parentId'` | 指定关联父节点的字段名。
|
|
118
|
-
| `childrenId` | `string` | `'children'` | 指定生成的树中用于存放子节点数组的字段名。
|
|
119
|
-
| `allowSelfAsParent` | `boolean` | `false` | 是否允许一个节点的 `parentId` 等于它自身的 `id`。
|
|
120
|
-
| `rootId` | `string` | `'__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__'` | 内部使用的虚拟根 ID,通常不需要修改。根节点的 `parentId` 应为 `null`
|
|
114
|
+
| 选项 | 类型 | 默认值 | 描述 |
|
|
115
|
+
| ------------------- | --------- | ------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
116
|
+
| `customId` | `string` | `'id'` | 指定节点唯一标识的字段名。 |
|
|
117
|
+
| `parentId` | `string` | `'parentId'` | 指定关联父节点的字段名。 |
|
|
118
|
+
| `childrenId` | `string` | `'children'` | 指定生成的树中用于存放子节点数组的字段名。 |
|
|
119
|
+
| `allowSelfAsParent` | `boolean` | `false` | 是否允许一个节点的 `parentId` 等于它自身的 `id`。 |
|
|
120
|
+
| `rootId` | `string` | `'__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__'` | 内部使用的虚拟根 ID,通常不需要修改。根节点的 `parentId` 应为 `null`、`undefined` 或空字符串 `""`。 |
|
|
121
121
|
|
|
122
122
|
#### 示例:使用自定义字段
|
|
123
123
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";class r extends Error{constructor(r){super(r),this.name="ArrayToTreeError"}}const t=(r,t)=>{const e=t.split(/[.[\]]/g);let n=r;for(const r of e){if(null===n)return null;if(void 0===n)return null;const t=r.replace(/['"]/g,"");""!==t.trim()&&(n=n[t])}return void 0===n?null:n},e=(r,n,o,s)=>Array.isArray(n)?n.map(n=>{const a={...n},d=t(n,o),c=null!=d?r[d]:void 0;return c&&(a[s]=e(r,c,o,s)),a}):[];exports.ArrayToTreeError=r,exports.arrayToTree=(n,o)=>{const s=(r=>({allowSelfAsParent:(r=r??{}).allowSelfAsParent??!1,childrenId:r.childrenId??"children",customId:r.customId??"id",parentId:r.parentId??"parentId",rootId:r.rootId??"__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__"}))(o);if(!Array.isArray(n))throw new r("Expected an array but got an invalid argument.");const a=((e,n)=>{const o={};for(const s of e){const e=t(s,n.customId);if(null!=e&&Object.hasOwn(o,e))throw new r(`Duplicate node id "${e}" detected.`);o[e]=s}const s=new Set;return e.reduce((e,a)=>{const d=t(a,n.customId);let c=t(a,n.parentId);if(c===d){if(!n.allowSelfAsParent)throw new r(`Node "${d}" cannot be its own parent (self reference found).`);c=n.rootId}if(null!=d&&!s.has(d)){const e=new Set([d]);let a=c;for(;a&&a!==n.rootId&&!s.has(a);){if(e.has(a)){const t=[...e,a].join(" -> ");throw new r(`Cycle detected in parent chain: ${t}`)}e.add(a);const s=o[a];if(!s)break;a=t(s,n.parentId)}for(const r of e)s.add(r)}return c&&Object.hasOwn(o,c)||(c=n.rootId),Object.hasOwn(e,c)?e[c].push(a):e[c]=[a],e},{})})(n,s);return e(a,a[s.rootId],s.customId,s.childrenId)};
|
|
2
|
-
//# sourceMappingURL=index.
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/errors/array-to-tree-error.ts","../../../../src/internal/get.ts","../../../../src/internal/create-tree.ts","../../../../src/utils/array-to-tree.ts","../../../../src/internal/resolve-options.ts","../../../../src/internal/group-by-parents.ts"],"sourcesContent":["export class ArrayToTreeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ArrayToTreeError\";\n }\n}\n","/**\n * This code is modified from the radash project.\n * @see https://github.com/sodiray/radash\n */\nexport const get = (value: any, path: string) => {\n const segments = path.split(/[.[\\]]/g);\n let current: any = value;\n for (const key of segments) {\n if (current === null) return null;\n if (current === undefined) return null;\n const dequoted = key.replace(/['\"]/g, \"\");\n if (dequoted.trim() === \"\") continue;\n current = current[dequoted];\n }\n if (current === undefined) return null;\n return current;\n};\n","import { get } from \"./get\";\n\nexport const createTree = (\n grouped: Record<string, any[]>,\n rootNodes: any[],\n customId: string,\n childrenProperty: string,\n) => {\n if (!Array.isArray(rootNodes)) {\n return [];\n }\n\n return rootNodes.map((node) => {\n const newNode = { ...node };\n const nodeId = get(node, customId);\n const children = nodeId != null ? grouped[nodeId] : undefined;\n if (children) {\n newNode[childrenProperty] = createTree(\n grouped,\n children,\n customId,\n childrenProperty,\n );\n }\n return newNode;\n });\n};\n","import { ArrayToTreeError } from \"../errors\";\nimport { createTree, groupByParents, resolveOptions } from \"../internal\";\nimport type {\n ArrayToTreeOptions,\n NormalizedArrayToTreeOptions,\n} from \"../types\";\n\nexport const arrayToTree = (\n data: Record<string, any>[],\n options?: ArrayToTreeOptions,\n) => {\n const normalizeOptions = resolveOptions(\n options,\n ) as NormalizedArrayToTreeOptions;\n\n if (!Array.isArray(data)) {\n throw new ArrayToTreeError(\n \"Expected an array but got an invalid argument.\",\n );\n }\n\n const grouped = groupByParents(data, normalizeOptions);\n\n return createTree(\n grouped,\n grouped[normalizeOptions.rootId],\n normalizeOptions.customId,\n normalizeOptions.childrenId,\n );\n};\n","import type { ArrayToTreeOptions } from \"../types\";\n\nexport const resolveOptions = (\n options?: ArrayToTreeOptions,\n): Required<ArrayToTreeOptions> => {\n options = options ?? {};\n return {\n allowSelfAsParent: options.allowSelfAsParent ?? false,\n childrenId: options.childrenId ?? \"children\",\n customId: options.customId ?? \"id\",\n parentId: options.parentId ?? \"parentId\",\n rootId: options.rootId ?? \"__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__\",\n };\n};\n","import { ArrayToTreeError } from \"../errors\";\nimport type { NormalizedArrayToTreeOptions } from \"../types\";\nimport { get } from \"./get\";\n\nexport const groupByParents = (\n array: Record<string, any>[],\n options: NormalizedArrayToTreeOptions,\n) => {\n const arrayById: Record<string, any> = {};\n\n // 第一次遍历:构建索引并检测重复 id\n for (const item of array) {\n const key = get(item, options.customId);\n if (key != null && Object.hasOwn(arrayById, key)) {\n throw new ArrayToTreeError(`Duplicate node id \"${key}\" detected.`);\n }\n arrayById[key] = item;\n }\n\n const safe = new Set<any>();\n\n return array.reduce<Record<string, any[]>>((grouped, item) => {\n const id = get(item, options.customId);\n let parentId = get(item, options.parentId);\n\n // 1. 先处理自指节点\n if (parentId === id) {\n if (!options.allowSelfAsParent) {\n throw new ArrayToTreeError(\n `Node \"${id}\" cannot be its own parent (self reference found).`,\n );\n }\n parentId = options.rootId;\n }\n\n if (id != null && !safe.has(id)) {\n const path = new Set<any>([id]);\n let cursor = parentId;\n\n while (cursor && cursor !== options.rootId) {\n if (safe.has(cursor)) {\n break;\n }\n if (path.has(cursor)) {\n const cyclePath = [...path, cursor].join(\" -> \");\n throw new ArrayToTreeError(\n `Cycle detected in parent chain: ${cyclePath}`,\n );\n }\n path.add(cursor);\n\n const parentNode = arrayById[cursor];\n if (!parentNode) {\n break;\n }\n cursor = get(parentNode, options.parentId);\n }\n for (const n of path) safe.add(n);\n }\n\n if (!parentId || !Object.hasOwn(arrayById, parentId)) {\n parentId = options.rootId;\n }\n\n if (Object.hasOwn(grouped, parentId)) {\n grouped[parentId].push(item);\n } else {\n grouped[parentId] = [item];\n }\n return grouped;\n }, {});\n};\n"],"names":["ArrayToTreeError","Error","constructor","message","super","this","name","get","value","path","segments","split","current","key","undefined","dequoted","replace","trim","createTree","grouped","rootNodes","customId","childrenProperty","Array","isArray","map","node","newNode","nodeId","children","data","options","normalizeOptions","allowSelfAsParent","childrenId","parentId","rootId","resolveOptions","array","arrayById","item","Object","hasOwn","safe","Set","reduce","id","has","cursor","cyclePath","join","add","parentNode","n","push","groupByParents"],"mappings":"aAAM,MAAOA,UAAyBC,MACpC,WAAAC,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,kBACd,ECAK,MAAMC,EAAM,CAACC,EAAYC,KAC9B,MAAMC,EAAWD,EAAKE,MAAM,WAC5B,IAAIC,EAAeJ,EACnB,IAAK,MAAMK,KAAOH,EAAU,CAC1B,GAAgB,OAAZE,EAAkB,OAAO,KAC7B,QAAgBE,IAAZF,EAAuB,OAAO,KAClC,MAAMG,EAAWF,EAAIG,QAAQ,QAAS,IACd,KAApBD,EAASE,SACbL,EAAUA,EAAQG,GACpB,CACA,YAAgBD,IAAZF,EAA8B,KAC3BA,GCbIM,EAAa,CACxBC,EACAC,EACAC,EACAC,IAEKC,MAAMC,QAAQJ,GAIZA,EAAUK,IAAKC,IACpB,MAAMC,EAAU,IAAKD,GACfE,EAASrB,EAAImB,EAAML,GACnBQ,EAAqB,MAAVD,EAAiBT,EAAQS,QAAUd,EASpD,OARIe,IACFF,EAAQL,GAAoBJ,EAC1BC,EACAU,EACAR,EACAC,IAGGK,IAfA,kDCFgB,CACzBG,EACAC,KAEA,MAAMC,ECTsB,CAC5BD,IAGO,CACLE,mBAFFF,EAAUA,GAAW,CAAA,GAEQE,oBAAqB,EAChDC,WAAYH,EAAQG,YAAc,WAClCb,SAAUU,EAAQV,UAAY,KAC9Bc,SAAUJ,EAAQI,UAAY,WAC9BC,OAAQL,EAAQK,QAAU,sCDAHC,CACvBN,GAGF,IAAKR,MAAMC,QAAQM,GACjB,MAAM,IAAI9B,EACR,kDAIJ,MAAMmB,EEjBsB,EAC5BmB,EACAP,KAEA,MAAMQ,EAAiC,CAAA,EAGvC,I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1,2 @@
|
|
|
1
1
|
class t extends Error{constructor(t){super(t),this.name="ArrayToTreeError"}}const r=(t,r)=>{const e=r.split(/[.[\]]/g);let n=t;for(const t of e){if(null===n)return null;if(void 0===n)return null;const r=t.replace(/['"]/g,"");""!==r.trim()&&(n=n[r])}return void 0===n?null:n},e=(t,n,o,d)=>Array.isArray(n)?n.map(n=>{const s={...n},c=r(n,o),a=null!=c?t[c]:void 0;return a&&(s[d]=e(t,a,o,d)),s}):[],n=(n,o)=>{const d=(t=>({allowSelfAsParent:(t=t??{}).allowSelfAsParent??!1,childrenId:t.childrenId??"children",customId:t.customId??"id",parentId:t.parentId??"parentId",rootId:t.rootId??"__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__"}))(o);if(!Array.isArray(n))throw new t("Expected an array but got an invalid argument.");const s=((e,n)=>{const o={};for(const d of e){const e=r(d,n.customId);if(null!=e&&Object.hasOwn(o,e))throw new t(`Duplicate node id "${e}" detected.`);o[e]=d}const d=new Set;return e.reduce((e,s)=>{const c=r(s,n.customId);let a=r(s,n.parentId);if(a===c){if(!n.allowSelfAsParent)throw new t(`Node "${c}" cannot be its own parent (self reference found).`);a=n.rootId}if(null!=c&&!d.has(c)){const e=new Set([c]);let s=a;for(;s&&s!==n.rootId&&!d.has(s);){if(e.has(s)){const r=[...e,s].join(" -> ");throw new t(`Cycle detected in parent chain: ${r}`)}e.add(s);const d=o[s];if(!d)break;s=r(d,n.parentId)}for(const t of e)d.add(t)}return a&&Object.hasOwn(o,a)||(a=n.rootId),Object.hasOwn(e,a)?e[a].push(s):e[a]=[s],e},{})})(n,d);return e(s,s[d.rootId],d.customId,d.childrenId)};export{t as ArrayToTreeError,n as arrayToTree};
|
|
2
|
-
//# sourceMappingURL=index.
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../src/errors/array-to-tree-error.ts","../../../../src/internal/get.ts","../../../../src/internal/create-tree.ts","../../../../src/utils/array-to-tree.ts","../../../../src/internal/resolve-options.ts","../../../../src/internal/group-by-parents.ts"],"sourcesContent":["export class ArrayToTreeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ArrayToTreeError\";\n }\n}\n","/**\n * This code is modified from the radash project.\n * @see https://github.com/sodiray/radash\n */\nexport const get = (value: any, path: string) => {\n const segments = path.split(/[.[\\]]/g);\n let current: any = value;\n for (const key of segments) {\n if (current === null) return null;\n if (current === undefined) return null;\n const dequoted = key.replace(/['\"]/g, \"\");\n if (dequoted.trim() === \"\") continue;\n current = current[dequoted];\n }\n if (current === undefined) return null;\n return current;\n};\n","import { get } from \"./get\";\n\nexport const createTree = (\n grouped: Record<string, any[]>,\n rootNodes: any[],\n customId: string,\n childrenProperty: string,\n) => {\n if (!Array.isArray(rootNodes)) {\n return [];\n }\n\n return rootNodes.map((node) => {\n const newNode = { ...node };\n const nodeId = get(node, customId);\n const children = nodeId != null ? grouped[nodeId] : undefined;\n if (children) {\n newNode[childrenProperty] = createTree(\n grouped,\n children,\n customId,\n childrenProperty,\n );\n }\n return newNode;\n });\n};\n","import { ArrayToTreeError } from \"../errors\";\nimport { createTree, groupByParents, resolveOptions } from \"../internal\";\nimport type {\n ArrayToTreeOptions,\n NormalizedArrayToTreeOptions,\n} from \"../types\";\n\nexport const arrayToTree = (\n data: Record<string, any>[],\n options?: ArrayToTreeOptions,\n) => {\n const normalizeOptions = resolveOptions(\n options,\n ) as NormalizedArrayToTreeOptions;\n\n if (!Array.isArray(data)) {\n throw new ArrayToTreeError(\n \"Expected an array but got an invalid argument.\",\n );\n }\n\n const grouped = groupByParents(data, normalizeOptions);\n\n return createTree(\n grouped,\n grouped[normalizeOptions.rootId],\n normalizeOptions.customId,\n normalizeOptions.childrenId,\n );\n};\n","import type { ArrayToTreeOptions } from \"../types\";\n\nexport const resolveOptions = (\n options?: ArrayToTreeOptions,\n): Required<ArrayToTreeOptions> => {\n options = options ?? {};\n return {\n allowSelfAsParent: options.allowSelfAsParent ?? false,\n childrenId: options.childrenId ?? \"children\",\n customId: options.customId ?? \"id\",\n parentId: options.parentId ?? \"parentId\",\n rootId: options.rootId ?? \"__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__\",\n };\n};\n","import { ArrayToTreeError } from \"../errors\";\nimport type { NormalizedArrayToTreeOptions } from \"../types\";\nimport { get } from \"./get\";\n\nexport const groupByParents = (\n array: Record<string, any>[],\n options: NormalizedArrayToTreeOptions,\n) => {\n const arrayById: Record<string, any> = {};\n\n // 第一次遍历:构建索引并检测重复 id\n for (const item of array) {\n const key = get(item, options.customId);\n if (key != null && Object.hasOwn(arrayById, key)) {\n throw new ArrayToTreeError(`Duplicate node id \"${key}\" detected.`);\n }\n arrayById[key] = item;\n }\n\n const safe = new Set<any>();\n\n return array.reduce<Record<string, any[]>>((grouped, item) => {\n const id = get(item, options.customId);\n let parentId = get(item, options.parentId);\n\n // 1. 先处理自指节点\n if (parentId === id) {\n if (!options.allowSelfAsParent) {\n throw new ArrayToTreeError(\n `Node \"${id}\" cannot be its own parent (self reference found).`,\n );\n }\n parentId = options.rootId;\n }\n\n if (id != null && !safe.has(id)) {\n const path = new Set<any>([id]);\n let cursor = parentId;\n\n while (cursor && cursor !== options.rootId) {\n if (safe.has(cursor)) {\n break;\n }\n if (path.has(cursor)) {\n const cyclePath = [...path, cursor].join(\" -> \");\n throw new ArrayToTreeError(\n `Cycle detected in parent chain: ${cyclePath}`,\n );\n }\n path.add(cursor);\n\n const parentNode = arrayById[cursor];\n if (!parentNode) {\n break;\n }\n cursor = get(parentNode, options.parentId);\n }\n for (const n of path) safe.add(n);\n }\n\n if (!parentId || !Object.hasOwn(arrayById, parentId)) {\n parentId = options.rootId;\n }\n\n if (Object.hasOwn(grouped, parentId)) {\n grouped[parentId].push(item);\n } else {\n grouped[parentId] = [item];\n }\n return grouped;\n }, {});\n};\n"],"names":["ArrayToTreeError","Error","constructor","message","super","this","name","get","value","path","segments","split","current","key","undefined","dequoted","replace","trim","createTree","grouped","rootNodes","customId","childrenProperty","Array","isArray","map","node","newNode","nodeId","children","arrayToTree","data","options","normalizeOptions","allowSelfAsParent","childrenId","parentId","rootId","resolveOptions","array","arrayById","item","Object","hasOwn","safe","Set","reduce","id","has","cursor","cyclePath","join","add","parentNode","n","push","groupByParents"],"mappings":"AAAM,MAAOA,UAAyBC,MACpC,WAAAC,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,kBACd,ECAK,MAAMC,EAAM,CAACC,EAAYC,KAC9B,MAAMC,EAAWD,EAAKE,MAAM,WAC5B,IAAIC,EAAeJ,EACnB,IAAK,MAAMK,KAAOH,EAAU,CAC1B,GAAgB,OAAZE,EAAkB,OAAO,KAC7B,QAAgBE,IAAZF,EAAuB,OAAO,KAClC,MAAMG,EAAWF,EAAIG,QAAQ,QAAS,IACd,KAApBD,EAASE,SACbL,EAAUA,EAAQG,GACpB,CACA,YAAgBD,IAAZF,EAA8B,KAC3BA,GCbIM,EAAa,CACxBC,EACAC,EACAC,EACAC,IAEKC,MAAMC,QAAQJ,GAIZA,EAAUK,IAAKC,IACpB,MAAMC,EAAU,IAAKD,GACfE,EAASrB,EAAImB,EAAML,GACnBQ,EAAqB,MAAVD,EAAiBT,EAAQS,QAAUd,EASpD,OARIe,IACFF,EAAQL,GAAoBJ,EAC1BC,EACAU,EACAR,EACAC,IAGGK,IAfA,GCFEG,EAAc,CACzBC,EACAC,KAEA,MAAMC,ECTsB,CAC5BD,IAGO,CACLE,mBAFFF,EAAUA,GAAW,CAAA,GAEQE,oBAAqB,EAChDC,WAAYH,EAAQG,YAAc,WAClCd,SAAUW,EAAQX,UAAY,KAC9Be,SAAUJ,EAAQI,UAAY,WAC9BC,OAAQL,EAAQK,QAAU,sCDAHC,CACvBN,GAGF,IAAKT,MAAMC,QAAQO,GACjB,MAAM,IAAI/B,EACR,kDAIJ,MAAMmB,EEjBsB,EAC5BoB,EACAP,KAEA,MAAMQ,EAAiC,CAAA,EAGvC,IAAK,MAAMC,K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6 +50,8 @@
|
|
|
50
50
|
"type": "git",
|
|
51
51
|
"url": "git+https://github.com/okutils/array-to-tree.git"
|
|
52
52
|
},
|
|
53
|
+
"type": "module",
|
|
54
|
+
"version": "0.0.3a",
|
|
53
55
|
"scripts": {
|
|
54
56
|
"build": "pnpm clean && rollup -c",
|
|
55
57
|
"clean": "rimraf dist",
|
|
@@ -59,7 +61,5 @@
|
|
|
59
61
|
"lint:fix": "biome check --write .",
|
|
60
62
|
"test": "jest",
|
|
61
63
|
"type-check": "tsc --noEmit"
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
"version": "0.0.2"
|
|
65
|
-
}
|
|
64
|
+
}
|
|
65
|
+
}
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/errors/array-to-tree-error.ts","../../../../src/internal/get.ts","../../../../src/internal/create-tree.ts","../../../../src/utils/array-to-tree.ts","../../../../src/internal/resolve-options.ts","../../../../src/internal/group-by-parents.ts"],"sourcesContent":["export class ArrayToTreeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ArrayToTreeError\";\n }\n}\n","/**\n * This code is modified from the radash project.\n * @see https://github.com/sodiray/radash\n */\nexport const get = (value: any, path: string) => {\n const segments = path.split(/[.[\\]]/g);\n let current: any = value;\n for (const key of segments) {\n if (current === null) return null;\n if (current === undefined) return null;\n const dequoted = key.replace(/['\"]/g, \"\");\n if (dequoted.trim() === \"\") continue;\n current = current[dequoted];\n }\n if (current === undefined) return null;\n return current;\n};\n","import { get } from \"./get\";\n\nexport const createTree = (\n grouped: Record<string, any[]>,\n rootNodes: any[],\n customId: string,\n childrenProperty: string,\n) => {\n if (!Array.isArray(rootNodes)) {\n return [];\n }\n\n return rootNodes.map((node) => {\n const newNode = { ...node };\n const nodeId = get(node, customId);\n const children = nodeId != null ? grouped[nodeId] : undefined;\n if (children) {\n newNode[childrenProperty] = createTree(\n grouped,\n children,\n customId,\n childrenProperty,\n );\n }\n return newNode;\n });\n};\n","import { ArrayToTreeError } from \"../errors\";\nimport { createTree, groupByParents, resolveOptions } from \"../internal\";\nimport type {\n ArrayToTreeOptions,\n NormalizedArrayToTreeOptions,\n} from \"../types\";\n\nexport const arrayToTree = (\n data: Record<string, any>[],\n options?: ArrayToTreeOptions,\n) => {\n const normalizeOptions = resolveOptions(\n options,\n ) as NormalizedArrayToTreeOptions;\n\n if (!Array.isArray(data)) {\n throw new ArrayToTreeError(\n \"Expected an array but got an invalid argument.\",\n );\n }\n\n const grouped = groupByParents(data, normalizeOptions);\n\n return createTree(\n grouped,\n grouped[normalizeOptions.rootId],\n normalizeOptions.customId,\n normalizeOptions.childrenId,\n );\n};\n","import type { ArrayToTreeOptions } from \"../types\";\n\nexport const resolveOptions = (\n options?: ArrayToTreeOptions,\n): Required<ArrayToTreeOptions> => {\n options = options ?? {};\n return {\n allowSelfAsParent: options.allowSelfAsParent ?? false,\n childrenId: options.childrenId ?? \"children\",\n customId: options.customId ?? \"id\",\n parentId: options.parentId ?? \"parentId\",\n rootId: options.rootId ?? \"__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__\",\n };\n};\n","import { ArrayToTreeError } from \"../errors\";\nimport type { NormalizedArrayToTreeOptions } from \"../types\";\nimport { get } from \"./get\";\n\nexport const groupByParents = (\n array: Record<string, any>[],\n options: NormalizedArrayToTreeOptions,\n) => {\n const arrayById: Record<string, any> = {};\n\n // 第一次遍历:构建索引并检测重复 id\n for (const item of array) {\n const key = get(item, options.customId);\n if (key != null && Object.hasOwn(arrayById, key)) {\n throw new ArrayToTreeError(`Duplicate node id \"${key}\" detected.`);\n }\n arrayById[key] = item;\n }\n\n const safe = new Set<any>();\n\n return array.reduce<Record<string, any[]>>((grouped, item) => {\n const id = get(item, options.customId);\n let parentId = get(item, options.parentId);\n\n // 1. 先处理自指节点\n if (parentId === id) {\n if (!options.allowSelfAsParent) {\n throw new ArrayToTreeError(\n `Node \"${id}\" cannot be its own parent (self reference found).`,\n );\n }\n parentId = options.rootId;\n }\n\n if (id != null && !safe.has(id)) {\n const path = new Set<any>([id]);\n let cursor = parentId;\n\n while (cursor && cursor !== options.rootId) {\n if (safe.has(cursor)) {\n break;\n }\n if (path.has(cursor)) {\n const cyclePath = [...path, cursor].join(\" -> \");\n throw new ArrayToTreeError(\n `Cycle detected in parent chain: ${cyclePath}`,\n );\n }\n path.add(cursor);\n\n const parentNode = arrayById[cursor];\n if (!parentNode) {\n break;\n }\n cursor = get(parentNode, options.parentId);\n }\n for (const n of path) safe.add(n);\n }\n\n if (!parentId || !Object.hasOwn(arrayById, parentId)) {\n parentId = options.rootId;\n }\n\n if (Object.hasOwn(grouped, parentId)) {\n grouped[parentId].push(item);\n } else {\n grouped[parentId] = [item];\n }\n return grouped;\n }, {});\n};\n"],"names":["ArrayToTreeError","Error","constructor","message","super","this","name","get","value","path","segments","split","current","key","undefined","dequoted","replace","trim","createTree","grouped","rootNodes","customId","childrenProperty","Array","isArray","map","node","newNode","nodeId","children","data","options","normalizeOptions","allowSelfAsParent","childrenId","parentId","rootId","resolveOptions","array","arrayById","item","Object","hasOwn","safe","Set","reduce","id","has","cursor","cyclePath","join","add","parentNode","n","push","groupByParents"],"mappings":"aAAM,MAAOA,UAAyBC,MACpC,WAAAC,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,kBACd,ECAK,MAAMC,EAAM,CAACC,EAAYC,KAC9B,MAAMC,EAAWD,EAAKE,MAAM,WAC5B,IAAIC,EAAeJ,EACnB,IAAK,MAAMK,KAAOH,EAAU,CAC1B,GAAgB,OAAZE,EAAkB,OAAO,KAC7B,QAAgBE,IAAZF,EAAuB,OAAO,KAClC,MAAMG,EAAWF,EAAIG,QAAQ,QAAS,IACd,KAApBD,EAASE,SACbL,EAAUA,EAAQG,GACpB,CACA,YAAgBD,IAAZF,EAA8B,KAC3BA,GCbIM,EAAa,CACxBC,EACAC,EACAC,EACAC,IAEKC,MAAMC,QAAQJ,GAIZA,EAAUK,IAAK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AY,IAAIxC,EAAMuC,GAAQE,KAAK,QACzC,MAAM,IAAIlD,EACR,mCAAmCiD,IAEvC,CACAxC,EAAK0C,IAAIH,GAET,MAAMI,EAAab,EAAUS,GAC7B,IAAKI,EACH,MAEFJ,EAASzC,EAAI6C,EAAYrB,EAAQI,SACnC,CACA,IAAK,MAAMkB,KAAK5C,EAAMkC,EAAKQ,IAAIE,EACjC,CAWA,OATKlB,GAAaM,OAAOC,OAAOH,EAAWJ,KACzCA,EAAWJ,EAAQK,QAGjBK,OAAOC,OAAOvB,EAASgB,GACzBhB,EAAQgB,GAAUmB,KAAKd,GAEvBrB,EAAQgB,GAAY,CAACK,GAEhBrB,GACN,CAAA,IFjDaoC,CAAezB,EAAME,GAErC,OAAOd,EACLC,EACAA,EAAQa,EAAiBI,QACzBJ,EAAiBX,SACjBW,EAAiBE"}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/errors/array-to-tree-error.ts","../../../../src/internal/get.ts","../../../../src/internal/create-tree.ts","../../../../src/utils/array-to-tree.ts","../../../../src/internal/resolve-options.ts","../../../../src/internal/group-by-parents.ts"],"sourcesContent":["export class ArrayToTreeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ArrayToTreeError\";\n }\n}\n","/**\n * This code is modified from the radash project.\n * @see https://github.com/sodiray/radash\n */\nexport const get = (value: any, path: string) => {\n const segments = path.split(/[.[\\]]/g);\n let current: any = value;\n for (const key of segments) {\n if (current === null) return null;\n if (current === undefined) return null;\n const dequoted = key.replace(/['\"]/g, \"\");\n if (dequoted.trim() === \"\") continue;\n current = current[dequoted];\n }\n if (current === undefined) return null;\n return current;\n};\n","import { get } from \"./get\";\n\nexport const createTree = (\n grouped: Record<string, any[]>,\n rootNodes: any[],\n customId: string,\n childrenProperty: string,\n) => {\n if (!Array.isArray(rootNodes)) {\n return [];\n }\n\n return rootNodes.map((node) => {\n const newNode = { ...node };\n const nodeId = get(node, customId);\n const children = nodeId != null ? grouped[nodeId] : undefined;\n if (children) {\n newNode[childrenProperty] = createTree(\n grouped,\n children,\n customId,\n childrenProperty,\n );\n }\n return newNode;\n });\n};\n","import { ArrayToTreeError } from \"../errors\";\nimport { createTree, groupByParents, resolveOptions } from \"../internal\";\nimport type {\n ArrayToTreeOptions,\n NormalizedArrayToTreeOptions,\n} from \"../types\";\n\nexport const arrayToTree = (\n data: Record<string, any>[],\n options?: ArrayToTreeOptions,\n) => {\n const normalizeOptions = resolveOptions(\n options,\n ) as NormalizedArrayToTreeOptions;\n\n if (!Array.isArray(data)) {\n throw new ArrayToTreeError(\n \"Expected an array but got an invalid argument.\",\n );\n }\n\n const grouped = groupByParents(data, normalizeOptions);\n\n return createTree(\n grouped,\n grouped[normalizeOptions.rootId],\n normalizeOptions.customId,\n normalizeOptions.childrenId,\n );\n};\n","import type { ArrayToTreeOptions } from \"../types\";\n\nexport const resolveOptions = (\n options?: ArrayToTreeOptions,\n): Required<ArrayToTreeOptions> => {\n options = options ?? {};\n return {\n allowSelfAsParent: options.allowSelfAsParent ?? false,\n childrenId: options.childrenId ?? \"children\",\n customId: options.customId ?? \"id\",\n parentId: options.parentId ?? \"parentId\",\n rootId: options.rootId ?? \"__ARRAY_TO_TREE_VIRTUAL_ROOT_ID__\",\n };\n};\n","import { ArrayToTreeError } from \"../errors\";\nimport type { NormalizedArrayToTreeOptions } from \"../types\";\nimport { get } from \"./get\";\n\nexport const groupByParents = (\n array: Record<string, any>[],\n options: NormalizedArrayToTreeOptions,\n) => {\n const arrayById: Record<string, any> = {};\n\n // 第一次遍历:构建索引并检测重复 id\n for (const item of array) {\n const key = get(item, options.customId);\n if (key != null && Object.hasOwn(arrayById, key)) {\n throw new ArrayToTreeError(`Duplicate node id \"${key}\" detected.`);\n }\n arrayById[key] = item;\n }\n\n const safe = new Set<any>();\n\n return array.reduce<Record<string, any[]>>((grouped, item) => {\n const id = get(item, options.customId);\n let parentId = get(item, options.parentId);\n\n // 1. 先处理自指节点\n if (parentId === id) {\n if (!options.allowSelfAsParent) {\n throw new ArrayToTreeError(\n `Node \"${id}\" cannot be its own parent (self reference found).`,\n );\n }\n parentId = options.rootId;\n }\n\n if (id != null && !safe.has(id)) {\n const path = new Set<any>([id]);\n let cursor = parentId;\n\n while (cursor && cursor !== options.rootId) {\n if (safe.has(cursor)) {\n break;\n }\n if (path.has(cursor)) {\n const cyclePath = [...path, cursor].join(\" -> \");\n throw new ArrayToTreeError(\n `Cycle detected in parent chain: ${cyclePath}`,\n );\n }\n path.add(cursor);\n\n const parentNode = arrayById[cursor];\n if (!parentNode) {\n break;\n }\n cursor = get(parentNode, options.parentId);\n }\n for (const n of path) safe.add(n);\n }\n\n if (!parentId || !Object.hasOwn(arrayById, parentId)) {\n parentId = options.rootId;\n }\n\n if (Object.hasOwn(grouped, parentId)) {\n grouped[parentId].push(item);\n } else {\n grouped[parentId] = [item];\n }\n return grouped;\n }, {});\n};\n"],"names":["ArrayToTreeError","Error","constructor","message","super","this","name","get","value","path","segments","split","current","key","undefined","dequoted","replace","trim","createTree","grouped","rootNodes","customId","childrenProperty","Array","isArray","map","node","newNode","nodeId","children","arrayToTree","data","options","normalizeOptions","allowSelfAsParent","childrenId","parentId","rootId","resolveOptions","array","arrayById","item","Object","hasOwn","safe","Set","reduce","id","has","cursor","cyclePath","join","add","parentNode","n","push","groupByParents"],"mappings":"AAAM,MAAOA,UAAyBC,MACpC,WAAAC,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,kBACd,ECAK,MAAMC,EAAM,CAACC,EAAYC,KAC9B,MAAMC,EAAWD,EAAKE,MAAM,WAC5B,IAAIC,EAAeJ,EACnB,IAAK,MAAMK,KAAOH,EAAU,CAC1B,GAAgB,OAAZE,EAAkB,OAAO,KAC7B,QAAgBE,IAAZF,EAAuB,OAAO,KAClC,MAAMG,EAAWF,EAAIG,QAAQ,QAAS,IACd,KAApBD,EAASE,SACbL,EAAUA,EAAQG,GACpB,CACA,YAAg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