utils.js 1.3 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. function t(t){return e(t,"",new Set,{})}function e(t,n,s,r){if(s.has(t))return r;s.add(t),n&&t.id&&(r[n]=t);for(const p of t.properties)if("string"!=typeof p.type){const t=n?`${n}.${p.name}`:p.name;e(p.type,t,s,r)}return s.delete(t),r}function n(t){const e=s(t,"",[]);return e.sort(((t,e)=>(t.name??"").localeCompare(e.name??""))),e}function s(t,e,n){for(const r of t.properties){const t=e?`${e}.${r.name}`:r.name;"string"==typeof r.type?n.push({name:t,type:r.type,default:r.default,enum:r.enum}):0===r.type.properties.length?n.push({name:t,type:"unknown",default:r.default,enum:r.enum}):s(r.type,t,n)}return n}class r{constructor(){this.stack=[],this.seen=new Map}addProperty(t){this.currentClass?.properties.push(t)}push(t,e){this.seen.set(e.id,e),this.stack.push({klass:e,propertyName:t})}pop(){return this.stack.pop()?.klass??null}get currentClass(){return this.stack.length?this.stack[this.stack.length-1].klass:null}get pathString(){return this.stack.map((t=>t.propertyName)).filter((t=>!!t)).join(".")}}function p(t){const e=t.slice();return e.sort(),e}export{r as ScanContext,t as collectClassPaths,n as flatten,p as sorted};