@gesslar/toolkit 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # npm i @gesslar/toolkit
1
+ # `npm i @gesslar/toolkit`
2
2
 
3
3
  This package is intended to be a collection of useful utilities for any
4
4
  project's consumption. Not the kind that gives you bleeding, hacking coughs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gesslar/toolkit",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Get in, bitches, we're going toolkitting.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Core file system abstractions
2
2
  export {default as FileObject} from "./lib/FileObject.js"
3
3
  export {default as DirectoryObject} from "./lib/DirectoryObject.js"
4
- export {default as FS, fdType, upperFdTypes, fdTypes} from "./lib/FS.js"
4
+ export {default as FS} from "./lib/FS.js"
5
5
 
6
6
  // Utility classes
7
7
  export {default as Cache} from "./lib/Cache.js"
@@ -209,18 +209,17 @@ export default class DirectoryObject extends FS {
209
209
  /**
210
210
  * Lists the contents of a directory.
211
211
  *
212
- * @param {DirectoryObject} directory - The directory to list.
213
212
  * @returns {Promise<{files: Array<FileObject>, directories: Array<DirectoryObject>}>} The files and directories in the directory.
214
213
  */
215
- async read(directory) {
214
+ async read() {
216
215
  const found = await fs.readdir(
217
- new URL(directory.uri),
216
+ new URL(this.uri),
218
217
  {withFileTypes: true}
219
218
  )
220
219
 
221
220
  const results = await Promise.all(
222
221
  found.map(async dirent => {
223
- const fullPath = path.join(directory.path, dirent.name)
222
+ const fullPath = path.join(this.path, dirent.name)
224
223
  const stat = await fs.stat(fullPath)
225
224
 
226
225
  return {dirent, stat, fullPath}
package/src/lib/FS.js CHANGED
@@ -12,9 +12,11 @@ const fdTypes = Object.freeze(["file", "directory"])
12
12
  const upperFdTypes = Object.freeze(fdTypes.map(type => type.toUpperCase()))
13
13
  const fdType = Object.freeze(await Data.allocateObject(upperFdTypes, fdTypes))
14
14
 
15
- export {fdType, upperFdTypes, fdTypes}
16
-
17
15
  export default class FS {
16
+ static fdTypes = fdTypes
17
+ static upperFdTypes = upperFdTypes
18
+ static fdType = fdType
19
+
18
20
  /**
19
21
  * Fix slashes in a path
20
22
  *
package/src/types/FS.d.ts CHANGED
@@ -8,6 +8,15 @@ import DirectoryObject from './DirectoryObject.js'
8
8
  * Base filesystem utilities class. FileObject and DirectoryObject extend this class.
9
9
  */
10
10
  export default class FS {
11
+ /** Array of lowercase file descriptor types */
12
+ static readonly fdTypes: readonly ["file", "directory"]
13
+
14
+ /** Array of uppercase file descriptor types */
15
+ static readonly upperFdTypes: readonly ["FILE", "DIRECTORY"]
16
+
17
+ /** Mapping from uppercase to lowercase file descriptor types */
18
+ static readonly fdType: Readonly<Record<"FILE" | "DIRECTORY", "file" | "directory">>
19
+
11
20
  /** Fix slashes in a path */
12
21
  static fixSlashes(pathName: string): string
13
22
 
@@ -29,18 +38,3 @@ export default class FS {
29
38
  /** Resolve a path relative to another path using various strategies. Handles absolute paths, relative navigation, and overlap-based merging */
30
39
  static resolvePath(fromPath: string, toPath: string): string
31
40
  }
32
-
33
- /**
34
- * File descriptor types as lowercase strings
35
- */
36
- export const fdTypes: readonly ["file", "directory"]
37
-
38
- /**
39
- * File descriptor types as uppercase strings
40
- */
41
- export const upperFdTypes: readonly ["FILE", "DIRECTORY"]
42
-
43
- /**
44
- * Mapping from uppercase file descriptor types to lowercase
45
- */
46
- export const fdType: Readonly<Record<"FILE" | "DIRECTORY", "file" | "directory">>
@@ -2,7 +2,7 @@
2
2
  // Core file system abstractions
3
3
  export { default as FileObject } from './FileObject.js'
4
4
  export { default as DirectoryObject } from './DirectoryObject.js'
5
- export { default as FS, fdType, upperFdTypes, fdTypes } from './FS.js'
5
+ export { default as FS } from './FS.js'
6
6
 
7
7
  // Utility classes
8
8
  export { default as Cache } from './Cache.js'