UNPKG

ll-package

Version:

2 lines (1 loc) 870 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s;(function(e){e[e.None=0]="None",e[e.Start=1]="Start",e[e.End=2]="End"})(s||(s={}));function l(e,i,u){function t(n){const f=n[i.key],o=n[i.children];u(f,n)!==!1&&l(o||[],i,u)}e.forEach(t)}function y(e){let{treeData:i,expandedKeys:u,startKey:t,endKey:n,fieldNames:f={title:"title",key:"key",children:"children"}}=e;const o=[];let r=s.None;if(t&&t===n)return[t];if(!t||!n)return[];function a(c){return c===t||c===n}return l(i,f,c=>{if(r===s.End)return!1;if(a(c)){if(o.push(c),r===s.None)r=s.Start;else if(r===s.Start)return r=s.End,!1}else r===s.Start&&o.push(c);return u.includes(c)}),o}function d(e,i,u){const t=[...i],n=[];return l(e,u,(f,o)=>{const r=t.indexOf(f);return r!==-1&&(n.push(o),t.splice(r,1)),!!t.length}),n}exports.calcRangeKeys=y;exports.convertDirectoryKeysToNodes=d;