Skip to content

Commit

Permalink
chore: Dash of readme
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Dec 8, 2023
1 parent d6a51f3 commit 4baddf6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions packages/io-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,19 @@ yarn install @layerzerolabs/io-utils
```bash
npm install @layerzerolabs/io-utils
```

## API Documentation

### Filesystem utilities

#### isDirectory(path)

Returns `true` if specified filesystem `path` points to a directory, `false` otherwise. Does not throw if `path` does not exist on the filesystem, instead returns `false`

#### isFile(path)

Returns `true` if specified filesystem `path` points to a file, `false` otherwise. Does not throw if `path` does not exist on the filesystem, instead returns `false`

#### isReadable(path)

Returns `true` if specified filesystem `path` can be read by the current user, `false` otherwise. Does not throw if `path` does not exist on the filesystem, instead returns `false`
6 changes: 3 additions & 3 deletions packages/io-utils/src/filesystem/filesystem.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { accessSync, constants, lstatSync } from 'fs'

export const isDirectory = (path: string) => {
export const isDirectory = (path: string): boolean => {
try {
return lstatSync(path).isDirectory()
} catch {
return false
}
}

export const isFile = (path: string) => {
export const isFile = (path: string): boolean => {
try {
return lstatSync(path).isFile()
} catch {
return false
}
}

export const isReadable = (path: string) => {
export const isReadable = (path: string): boolean => {
try {
return accessSync(path, constants.R_OK), true
} catch {
Expand Down

0 comments on commit 4baddf6

Please sign in to comment.