Skip to content

Commit

Permalink
Export the isSlice function
Browse files Browse the repository at this point in the history
  • Loading branch information
illright committed May 18, 2024
1 parent 8074751 commit ee36d72
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ Extract segments from all slices and layers of an FSD root. Returns a flat array

#### `isSliced`

> [!NOTE]
> Not to be confused with `isSlice`, a function that determines if a folder looks like a slice based on the segments that it contains.
```ts
export type LayerName =
| "shared"
Expand All @@ -189,4 +192,20 @@ function getIndex(fileOrFolder: File | Folder): File | undefined;

Get the index (public API) of a slice or segment. When a segment is a file, it is its own index.

#### `isSlice`

> [!NOTE]
> Not to be confused with `isSliced`, a function that determines if a layer should contain slices according to FSD.
```ts
function isSlice(
folder: Folder,
additionalSegmentNames: Array<string> = [],
): boolean;
```

Determine if this folder is a slice.

Slices are defined as folders that contain at least one segment. Additional segment names can be provided if some slice in project contains only unconventional segments.

[feature-sliced-design]: https://feature-sliced.design
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@feature-sliced/filesystem",
"version": "2.1.0",
"version": "2.2.0",
"description": "A set of utilities for locating and working with FSD roots in the file system.",
"scripts": {
"build": "tsup src/index.ts --dts --format esm,cjs --clean",
Expand Down
2 changes: 1 addition & 1 deletion src/fsd-aware-traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function getIndex(fileOrFolder: File | Folder): File | undefined {
* Slices are defined as folders that contain at least one segment.
* Additional segment names can be provided if some slice in project contains only unconventional segments.
*/
function isSlice(
export function isSlice(
folder: Folder,
additionalSegmentNames: Array<string> = [],
): boolean {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export {
getAllSegments,
isSliced,
getIndex,
isSlice,
} from "./fsd-aware-traverse.js";
export { resolveImport } from "./resolve-import.js";
export type * from "./definitions.js";
Expand Down

0 comments on commit ee36d72

Please sign in to comment.