You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A set of traversal functions for a simple representation of a file system:
72
+
73
+
```ts
74
+
exportinterfaceFile {
75
+
type:"file";
76
+
path:string;
77
+
}
78
+
79
+
exportinterfaceFolder {
80
+
type:"folder";
81
+
path:string;
82
+
children:Array<File|Folder>;
83
+
}
84
+
```
85
+
86
+
### `getLayers`
87
+
88
+
```ts
89
+
exporttypeLayerName=
90
+
|"shared"
91
+
|"entities"
92
+
|"features"
93
+
|"widgets"
94
+
|"pages"
95
+
|"app";
96
+
97
+
function getLayers(fsdRoot:Folder):Partial<Record<LayerName, Folder>>;
98
+
```
99
+
100
+
Extract layers from an FSD root. Returns a mapping of layer name to folder object.
101
+
102
+
### `getSlices`
103
+
104
+
```ts
105
+
function getSlices(
106
+
slicedLayer:Folder,
107
+
additionalSegmentNames:Array<string> = [],
108
+
):Record<string, Folder>;
109
+
```
110
+
111
+
Extract slices from a **sliced** layer. Returns a mapping of slice name (potentially containing slashes) to folder object.
112
+
113
+
A folder is detected as a slice when it has at least one folder/file with a name of a conventional segment (`ui`, `api`, `model`, `lib`, `config`). If your project contains slices that don't have those segments, you can provide additional segment names.
114
+
115
+
### `getSegments`
116
+
117
+
```ts
118
+
function getSegments(
119
+
sliceOrUnslicedLayer:Folder,
120
+
):Record<string, Folder|File>;
121
+
```
122
+
123
+
Extract segments from a slice or an **unsliced** layer. Returns a mapping of segment name to folder or file object.
124
+
125
+
### `getAllSlices`
126
+
127
+
```ts
128
+
function getAllSlices(
129
+
fsdRoot:Folder,
130
+
additionalSegmentNames:Array<string> = [],
131
+
):Record<string, Folder>;
132
+
```
133
+
134
+
Extract slices from all layers of an FSD root. Returns a mapping of slice name (potentially containing slashes) to folder object.
135
+
136
+
A folder is detected as a slice when it has at least one folder/file with a name of a conventional segment (`ui`, `api`, `model`, `lib`, `config`). If your project contains slices that don't have those segments, you can provide additional segment names.
137
+
138
+
### `isSliced`
139
+
140
+
```ts
141
+
exporttypeLayerName=
142
+
|"shared"
143
+
|"entities"
144
+
|"features"
145
+
|"widgets"
146
+
|"pages"
147
+
|"app";
148
+
149
+
function isSliced(layerOrName:Folder|LayerName):boolean;
150
+
```
151
+
152
+
Determine if this layer is sliced. You can pass the folder of a layer or the name (lowercase). Only layers Shared and App are not sliced, the rest are.
153
+
154
+
### `getIndex`
155
+
156
+
```ts
157
+
function getIndex(fileOrFolder:File|Folder):File|undefined;
158
+
```
159
+
160
+
Get the index (public API) of a slice or segment. When a segment is a file, it is its own index.
0 commit comments