instrumentality 0.0.7 → 0.0.9

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,9 +1,7 @@
1
- ![white title](./assets/titleLight.webp)
2
-
3
-
4
1
  ## The INSTRUMENTALITY project (concept)
5
2
  A utility library for TypeScript/Node.js
6
3
 
4
+ ![white title](./assets/titleLight.webp)
7
5
 
8
6
  #
9
7
  ### What is this?
@@ -13,13 +11,13 @@ A combination of files to handle TS/JS by itself, Node and DOM (for web) that pr
13
11
  #
14
12
  ### How to use
15
13
  ```sh
16
- npm install git+https://github.com/clerkburk/ts-instrumentality.git
14
+ npm install instrumentality
17
15
  ```
18
16
  then
19
17
  ```ts
20
18
  import * as ins from "instrumentality" // Base
21
19
  import * as ind from "instrumentality/dom" // Browser (if available)
22
- import * as inr from "instrumentality/road" // Filesystem using Node.js (if available)
20
+ import * as inr from "instrumentality/road" // Filesystem using Node.js (if available, deno 2 support is experimental)
23
21
  ```
24
22
  thats literally it
25
23
 
package/dist/base.d.ts CHANGED
@@ -1,27 +1,27 @@
1
1
  /** Subclass of {@link Error} that represents an error thrown from this library, providing a specific name for easier identification. */
2
- export declare class InsErr extends Error {
2
+ export declare class Err extends Error {
3
3
  name: string;
4
4
  }
5
+ export { Err as InsErr };
5
6
  /**
6
- * Retries a function multiple times with optional error handling and abort signal.
7
+ * Retries a function multiple times until it succeeds or the maximum number of attempts is reached, or the error callback indicates to stop.
7
8
  *
8
9
  * @param fn_ - The function to be retried.
9
10
  * @param maxAttempts_ - The maximum number of attempts to execute the function.
10
- * @param cbErr_ - An optional callback function to be executed after each failed attempt.
11
- * @param abs_ - An optional AbortSignal to abort the retry process.
11
+ * @param cbErr_ - An optional callback function that is invoked when an error occurs. It receives the error and the remaining number of attempts as arguments and should return `true` to continue retrying or `false` to stop.
12
12
  * @returns The result of {@link fn_} if it succeeds within the allowed attempts.
13
- * @throws {unknown} If {@link fn_} fails after the maximum attempts, the last error thrown by {@link fn_} is re-thrown.
14
- * @throws {InsErr} If the maximum attempts is less than 1 or if the operation is aborted.
13
+ * @throws the last error thrown by {@link fn_} if it fails after the maximum attempts or if the error callback indicates to stop.
14
+ * @throws If {@link cbErr_} throws or returns a rejected promise, the error is propagated immediately.
15
+ * @throws {InsErr} If {@link maxAttempts_} isn't a positive integer.
15
16
  */
16
- export declare function retry<T>(fn_: () => T, maxAttempts_: number, cbErr_?: () => unknown, abs_?: AbortSignal): Promise<T>;
17
+ export declare function retry<T>(fn_: () => T | PromiseLike<T>, maxAttempts_: number, cbErr_?: (err: unknown, remainingAttempts: number) => boolean | PromiseLike<boolean>): Promise<T>;
17
18
  /**
18
- * Asynchronously sleep.
19
+ * Alias for `setTimeout`.
19
20
  *
20
21
  * @param ms_ - The number of milliseconds to sleep.
21
- * @param abs_ - An optional AbortSignal to abort the sleep.
22
- * @throws {InsErr} If the sleep is aborted before or during the wait.
22
+ * @remarks The delay is a minimum, not an exact duration. The actual elapsed time also includes timer scheduling, event-loop latency, and promise-continuation overhead, so it may exceed {@link ms_}, especially for short delays.
23
23
  */
24
- export declare function sleep(ms_: number, abs_?: AbortSignal): Promise<void>;
24
+ export declare function sleep(ms_: number): Promise<void>;
25
25
  /**
26
26
  * Build a tuple of a specified length.
27
27
  *
@@ -115,7 +115,6 @@ export declare const BASE122_SHORT: 7;
115
115
  *
116
116
  * @param data_ - An array-like object containing the data to be encoded.
117
117
  * @returns A string representing the base-122 encoded data.
118
- * @throws If somehow malformed UTF-8 data is generated, the {@link TextDecoder} will throw an error (shouldn't happen if the input is valid).
119
118
  * @remarks The high density might not be suitable for all use cases, especially if the medium used to transmit the data has limitations on character sets or encoding.
120
119
  * @see {@link TextDecoder} how the output string is generated from the byte array (this step is necessary for accurate translation to a string).
121
120
  */
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,wIAAwI;AACxI,qBAAa,MAAO,SA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AAI,KAAK,EAAE,SAAS,IAAI,SAAS,EAAE,CAAA;AAIzE,uGAAuG;AACvG,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,EACxC,IAAI,GACJ,UAAU,GACV,SAAS,GACT,aAAa,GACb,MAAM,GACN,WAAW,GACX,UAAU,GACV,eAAe,GACf,OAAO,GACP,MAAM,GACN,SAAS,GACT,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,MAAM,CAAC,QAAQ,GACtB,QAAQ,GACR,aAAa,GACb,MAAM,GACN,gBAAgB,GAChB,UAAU,GACV,KAAK,GACL,QAAQ,GACR,OAAO,GACP,YAAY,GACZ,UAAU,GACV,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,YAAY,CACf,GAAG;IAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAA;AAIpC,yJAAyJ;AACzJ,eAAO,MAAM,eAAe,YAAI,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAU,CAAA;AAC/D,iHAAiH;AACjH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOzD,CAAA;AACV,8JAA8J;AAC9J,eAAO,MAAM,aAAa,EAAG,CAAc,CAAA;AAG3C;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAmC1D;AAGD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,2BAgCzC"}
package/dist/base.js CHANGED
@@ -1,56 +1,38 @@
1
1
  /** Subclass of {@link Error} that represents an error thrown from this library, providing a specific name for easier identification. */
2
- export class InsErr extends Error {
2
+ export class Err extends Error {
3
3
  name = "Instrumentality-Error";
4
4
  }
5
+ export { Err as InsErr };
5
6
  /**
6
- * Retries a function multiple times with optional error handling and abort signal.
7
+ * Retries a function multiple times until it succeeds or the maximum number of attempts is reached, or the error callback indicates to stop.
7
8
  *
8
9
  * @param fn_ - The function to be retried.
9
10
  * @param maxAttempts_ - The maximum number of attempts to execute the function.
10
- * @param cbErr_ - An optional callback function to be executed after each failed attempt.
11
- * @param abs_ - An optional AbortSignal to abort the retry process.
11
+ * @param cbErr_ - An optional callback function that is invoked when an error occurs. It receives the error and the remaining number of attempts as arguments and should return `true` to continue retrying or `false` to stop.
12
12
  * @returns The result of {@link fn_} if it succeeds within the allowed attempts.
13
- * @throws {unknown} If {@link fn_} fails after the maximum attempts, the last error thrown by {@link fn_} is re-thrown.
14
- * @throws {InsErr} If the maximum attempts is less than 1 or if the operation is aborted.
13
+ * @throws the last error thrown by {@link fn_} if it fails after the maximum attempts or if the error callback indicates to stop.
14
+ * @throws If {@link cbErr_} throws or returns a rejected promise, the error is propagated immediately.
15
+ * @throws {InsErr} If {@link maxAttempts_} isn't a positive integer.
15
16
  */
16
- export async function retry(fn_, maxAttempts_, cbErr_, abs_) {
17
- while (--maxAttempts_ >= 0 && !(abs_?.aborted ?? false))
17
+ export async function retry(fn_, maxAttempts_, cbErr_) {
18
+ if (!Number.isInteger(maxAttempts_) || maxAttempts_ < 1)
19
+ throw new Err("Max attempts isn't a positive integer");
20
+ while (true)
18
21
  try {
19
22
  return await fn_();
20
23
  }
21
24
  catch (err) {
22
- if (maxAttempts_ <= 0)
25
+ if (--maxAttempts_ <= 0 || (cbErr_ && !(await cbErr_(err, maxAttempts_))))
23
26
  throw err;
24
- await cbErr_?.();
25
27
  }
26
- if (maxAttempts_ < 0)
27
- throw new InsErr("Max attempts must be at least 1");
28
- else
29
- throw new InsErr("Operation aborted");
30
28
  }
31
29
  /**
32
- * Asynchronously sleep.
30
+ * Alias for `setTimeout`.
33
31
  *
34
32
  * @param ms_ - The number of milliseconds to sleep.
35
- * @param abs_ - An optional AbortSignal to abort the sleep.
36
- * @throws {InsErr} If the sleep is aborted before or during the wait.
33
+ * @remarks The delay is a minimum, not an exact duration. The actual elapsed time also includes timer scheduling, event-loop latency, and promise-continuation overhead, so it may exceed {@link ms_}, especially for short delays.
37
34
  */
38
- export async function sleep(ms_, abs_) {
39
- if (abs_?.aborted)
40
- return Promise.reject(new InsErr("Sleep aborted before start"));
41
- return new Promise((resolve, reject) => {
42
- const timeout = setTimeout(() => {
43
- abs_?.removeEventListener("abort", onAbort);
44
- resolve();
45
- }, ms_);
46
- function onAbort() {
47
- clearTimeout(timeout);
48
- abs_?.removeEventListener("abort", onAbort);
49
- reject(new InsErr("Sleep aborted during wait"));
50
- }
51
- abs_?.addEventListener("abort", onAbort, { once: true });
52
- });
53
- }
35
+ export function sleep(ms_) { return new Promise(r => setTimeout(r, ms_)); }
54
36
  /**
55
37
  * Wrapper around {@link performance.now}
56
38
  *
@@ -123,12 +105,12 @@ export const BASE122_SHORT = 0b111;
123
105
  *
124
106
  * @param data_ - An array-like object containing the data to be encoded.
125
107
  * @returns A string representing the base-122 encoded data.
126
- * @throws If somehow malformed UTF-8 data is generated, the {@link TextDecoder} will throw an error (shouldn't happen if the input is valid).
127
108
  * @remarks The high density might not be suitable for all use cases, especially if the medium used to transmit the data has limitations on character sets or encoding.
128
109
  * @see {@link TextDecoder} how the output string is generated from the byte array (this step is necessary for accurate translation to a string).
129
110
  */
130
111
  export function encode122(data_) {
131
- const out = [];
112
+ const out = new Uint8Array(2 * Math.ceil(data_.length * 8 / 7));
113
+ let outIndex = 0;
132
114
  let byteIndex = 0;
133
115
  let bitIndex = 0;
134
116
  function next7() {
@@ -149,14 +131,16 @@ export function encode122(data_) {
149
131
  for (let value = next7(); value !== undefined; value = next7()) {
150
132
  const illegalIndex = BASE122_ILLEGAL_INDEX[value];
151
133
  if (illegalIndex === undefined)
152
- out.push(value);
134
+ out[outIndex++] = value;
153
135
  else {
154
136
  const next = next7();
155
137
  const payload = next ?? value;
156
- out.push(0b11000010 | ((next === undefined ? BASE122_SHORT : illegalIndex) << 2) | (payload >>> 6), 0b10000000 | (payload & 0b00111111));
138
+ out[outIndex++] =
139
+ 0b11000010 | ((next === undefined ? BASE122_SHORT : illegalIndex) << 2) | (payload >>> 6),
140
+ out[outIndex++] = 0b10000000 | (payload & 0b00111111);
157
141
  }
158
142
  }
159
- return new TextDecoder("utf-8", { fatal: true }).decode(Uint8Array.from(out));
143
+ return new TextDecoder("utf-8", { fatal: true }).decode(out.subarray(0, outIndex));
160
144
  }
161
145
  /**
162
146
  * Decodes a base-122 encoded string back into its original byte representation.
@@ -190,7 +174,7 @@ export function decode122(base122_) {
190
174
  if (illegalIndex < BASE122_ILLEGAL.length)
191
175
  push7(BASE122_ILLEGAL[illegalIndex]);
192
176
  else if (illegalIndex !== BASE122_SHORT)
193
- throw new InsErr(`Invalid base-122 illegal index ${illegalIndex} at position ${i}`);
177
+ throw new Err(`Invalid base-122 illegal index ${illegalIndex} at position ${i}`);
194
178
  push7(code & 0b01111111);
195
179
  }
196
180
  return Uint8Array.from(out);
package/dist/dom.d.ts CHANGED
@@ -1,8 +1,3 @@
1
- import * as bs from "./base.ts";
2
- /** Subclass of {@link bs.InsErr} that represents an error thrown from this specific module of the library */
3
- export declare class DomErr extends bs.InsErr {
4
- name: string;
5
- }
6
1
  /**
7
2
  * Resolves on `DOMContentLoaded` or immediately if the document is already ready.
8
3
  */
@@ -19,7 +14,7 @@ export declare function byId<T extends HTMLElement>(id_: string, type_: new () =
19
14
  * Typed accessor for {@link document.getElementsByClassName}
20
15
  *
21
16
  * @param className_ - The class name of the elements to retrieve.
22
- * @param type_ - An optional constructor function for the expected element type.
17
+ * @param type_ - The constructor function for the expected element type.
23
18
  * @returns All elements with the specified class name and type.
24
19
  */
25
20
  export declare function byClass<T extends HTMLElement>(className_: string, type_: new () => T): T[];
package/dist/dom.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,WAAW,CAAA;AAI/B,6GAA6G;AA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AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAKrF;AAGD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,CAE1F;AAGD;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,qBAAqB,EAAE,IAAI,EAAE,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAEhG;AAID;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;IAC9C,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAA;CACrC,EAAE,KAAK,SAAM,GAAG,IAAI,CASpB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAM,GAAG,IAAI,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMjD"}
package/dist/dom.js CHANGED
@@ -1,8 +1,3 @@
1
- import * as bs from "./base.js";
2
- /** Subclass of {@link bs.InsErr} that represents an error thrown from this specific module of the library */
3
- export class DomErr extends bs.InsErr {
4
- name = "Instrumentality-DOM-Error";
5
- }
6
1
  /**
7
2
  * Resolves on `DOMContentLoaded` or immediately if the document is already ready.
8
3
  */
@@ -28,7 +23,7 @@ export function byId(id_, type_) {
28
23
  * Typed accessor for {@link document.getElementsByClassName}
29
24
  *
30
25
  * @param className_ - The class name of the elements to retrieve.
31
- * @param type_ - An optional constructor function for the expected element type.
26
+ * @param type_ - The constructor function for the expected element type.
32
27
  * @returns All elements with the specified class name and type.
33
28
  */
34
29
  export function byClass(className_, type_) {
package/dist/road.d.ts CHANGED
@@ -1,19 +1,30 @@
1
- import * as fs from "node:fs";
2
1
  import * as cr from "node:crypto";
3
- import * as bs from "./base.ts";
4
- /** Subclass of {@link bs.InsErr} that represents an error thrown from this specific module of the library */
5
- export declare class RdErr extends bs.InsErr {
2
+ import * as fs from "node:fs";
3
+ import * as fp from "node:fs/promises";
4
+ import { InsErr } from "./base.ts";
5
+ /** Subclass of {@link InsErr} that represents an error thrown from this specific module of the library */
6
+ export declare class Err extends InsErr {
6
7
  name: string;
7
8
  }
8
- export { RdErr as RoadError };
9
+ export { Err as RoadError, Err as RdErr };
9
10
  /**
10
11
  * Returns the constructor function corresponding to the file mode (statmode).
11
12
  *
12
- * @param statmode_ The file mode to check.
13
+ * @param statmode_ The file mode or {@link fs.Dirent} to check.
14
+ * @returns The constructor function corresponding to the road type (e.g., {@link File}, {@link Folder}, etc.).
15
+ * @throws If the file mode is unknown, throws a {@link Err}.
16
+ */
17
+ export declare function resolveStat(statmode_: number): typeof File | typeof Folder | typeof BlockDevice | typeof CharacterDevice | typeof SymbolicLink | typeof Fifo | typeof Socket;
18
+ export { resolveStat as resStat };
19
+ /**
20
+ * Returns the constructor function corresponding to the type of the given {@link fs.Dirent}.
21
+ *
22
+ * @param dirent The directory entry to check.
13
23
  * @returns The constructor function corresponding to the road type (e.g., {@link File}, {@link Folder}, etc.).
14
- * @throws If the file mode is unknown, throws a {@link RdErr}.
24
+ * @throws If the directory entry type is unknown, throws a {@link Err}.
15
25
  */
16
- export declare function resolveMode(statmode_: number): typeof File | typeof Folder | typeof BlockDevice | typeof CharacterDevice | typeof SymbolicLink | typeof Fifo | typeof Socket;
26
+ export declare function resolveDirent(dirent: fs.Dirent): typeof File | typeof Folder | typeof BlockDevice | typeof CharacterDevice | typeof SymbolicLink | typeof Fifo | typeof Socket;
27
+ export { resolveDirent as resDirent };
17
28
  /**
18
29
  * Creates the appropriate subclass of {@link Road} based on the file mode of the specified path.
19
30
  *
@@ -22,12 +33,14 @@ export declare function resolveMode(statmode_: number): typeof File | typeof Fol
22
33
  * @throws If {@link fp.lstat}/{@link fs.lstatSync} fails to retrieved the status of {@link path_}.
23
34
  */
24
35
  export declare function factory(path_: string): Promise<BlockDevice | CharacterDevice | Fifo | File | Folder | Socket | SymbolicLink>;
36
+ export { factory as fac, factory as mk };
25
37
  /** Sync version of {@link factory}. */
26
38
  export declare function factorySync(path_: string): BlockDevice | CharacterDevice | Fifo | File | Folder | Socket | SymbolicLink;
39
+ export { factorySync as facSync, factorySync as mkSync };
27
40
  /**
28
41
  * A map that keeps track of locked roads to prevent concurrent modifications.
29
42
  *
30
- * @key The absolute path of the road that is currently locked.
43
+ * @key The **absolute** and **normalized** (**resolved**) path of the road that is currently locked.
31
44
  * @value A promise that resolves when the lock on the road is released.
32
45
  *
33
46
  * @remarks The map is initialized lazily when the first lock is created to minimize import-time side effects.
@@ -62,25 +75,9 @@ export declare abstract class Road {
62
75
  * @param path_ Any path-like string that can be resolved to an absolute path. It will be resolved to an absolute path using {@link ph.resolve}.
63
76
  * @param typeCheck_ If true, the constructor will check if the path corresponds to the expected type of road (e.g., file, folder, etc.) and throw an error if it doesn't. If false, no type checking will be performed.
64
77
  *
65
- * @throws If {@link typeCheck_} is true and the path does not correspond to the expected type of road, a {@link RdErr} will be thrown.
66
- */
67
- constructor(path_: string, typeCheck_: boolean | 1 | 0);
68
- /**
69
- * Aquires a lock for the path represented by this Road instance, preventing concurrent modifications from this and other Road instances pointing to the same path.
70
- *
71
- * @param cb_ A callback function that will be called when the lock is released. This is used internally to manage the lock state.
72
- * @returns An object with a dispose method that releases the lock when called.
73
- * @throws If the road is immutable, a {@link RdErr} will be thrown.
74
- *
75
- * @remarks This method MUST be used with a `using` statement to ensure that the lock is released properly. Failing to do so may result in deadlocks or other concurrency issues.
76
- * Non-deterministic release is unfortunately not possible due to the nature of JavaScript's garbage collection, thus the lock must be released deterministically by the user (to which the `using` statement is a convenient way to do so).
78
+ * @throws If {@link typeCheck_} is true and the path does not correspond to the expected type of road, a {@link Err} will be thrown.
77
79
  */
78
- protected lock(cb_?: () => void): Promise<AsyncDisposable & Disposable>;
79
- /**
80
- * Sync version of {@link lock}.
81
- * @throws Also throws a {@link RdErr} if the road is currently locked by another operation as it cannot wait for the lock to be released in a synchronous context.
82
- */
83
- protected lockSync(cb_?: () => void): Disposable & AsyncDisposable;
80
+ constructor(path_: string, typeCheck_: boolean);
84
81
  /** @returns An instance of {@link Folder} representing the parent directory of the current road. */
85
82
  parent(): Folder;
86
83
  /**
@@ -91,6 +88,11 @@ export declare abstract class Road {
91
88
  ancestorsIt(): Generator<Folder, void, unknown>;
92
89
  /** @returns An array of {@link Folder} instances representing the ancestors of the current road. */
93
90
  ancestors(): Folder[];
91
+ protected reserveLock(allowConcurrent: boolean): Disposable & {
92
+ previous: Promise<void> | undefined;
93
+ };
94
+ lock(): Promise<Disposable>;
95
+ lockSync(): Disposable;
94
96
  /**
95
97
  * Watches the current entry for changes and resolves when the entry becomes accessible (i.e., exists and can be accessed).
96
98
  *
@@ -114,18 +116,19 @@ export declare abstract class Road {
114
116
  lstat(): Promise<fs.Stats>;
115
117
  /** @returns The result of {@link fs.lstatSync} for the current entry. */
116
118
  lstatSync(): fs.Stats;
117
- /** @returns The result of {@link fp.stat} for the current entry. */
118
- stat(): Promise<fs.Stats>;
119
- /** @returns The result of {@link fs.statSync} for the current entry. */
120
- statSync(): fs.Stats;
121
- abstract delete(): Promise<void>;
122
- abstract deleteSync(): void;
123
- abstract moveSync(into_: Folder): void;
124
- abstract move(into_: Folder): Promise<void>;
125
- abstract copySync(into_: Folder): this;
126
- abstract copy(into_: Folder): Promise<this>;
127
- abstract renameSync(to_: string): void;
128
- abstract rename(to_: string): Promise<void>;
119
+ /** Get the size of the this entry in bytes. */
120
+ abstract size(): Promise<number>;
121
+ abstract sizeSync(): number;
122
+ /** Wrapper around {@link fp.rm} with locking. */
123
+ delete(): Promise<void>;
124
+ /** Wrapper around {@link fs.rmSync} with locking. */
125
+ deleteSync(): void;
126
+ copy(into_: Folder): Promise<this>;
127
+ copySync(into_: Folder): this;
128
+ move(into_: Folder): Promise<void>;
129
+ moveSync(into_: Folder): void;
130
+ rename(newName_: string): Promise<void>;
131
+ renameSync(newName_: string): void;
129
132
  abstract check(): Promise<boolean>;
130
133
  abstract checkSync(): boolean;
131
134
  /** Type narrowing for {@link File} (similar to `instanceof` without unnecessary runtime checks). */
@@ -136,10 +139,6 @@ export declare abstract class Road {
136
139
  isFolder(): this is Folder;
137
140
  /** Type narrowing for {@link Folder} (similar to `instanceof` without unnecessary runtime checks). */
138
141
  isDirectory(): this is Folder;
139
- /** Type narrowing for {@link Folder} (similar to `instanceof` without unnecessary runtime checks). */
140
- isDict(): this is Folder;
141
- /** Type narrowing for {@link Folder} (similar to `instanceof` without unnecessary runtime checks). */
142
- isDictionary(): this is Folder;
143
142
  /** Type narrowing for {@link SymbolicLink} (similar to `instanceof` without unnecessary runtime checks). */
144
143
  isSymlink(): this is SymbolicLink;
145
144
  /** Type narrowing for {@link SymbolicLink} (similar to `instanceof` without unnecessary runtime checks). */
@@ -155,48 +154,60 @@ export declare abstract class Road {
155
154
  /** Type narrowing for {@link Socket} (similar to `instanceof` without unnecessary runtime checks). */
156
155
  isSocket(): this is Socket;
157
156
  }
158
- export type road_t = ConstructorParameters<typeof Road>;
157
+ /** Constructor type for a subclass of {@link Road}. */
158
+ export type road_t<T extends Road> = new (...args_: ConstructorParameters<typeof Road>) => T;
159
159
  /** Subclass of {@link Road} that represents a file. */
160
160
  export declare class File extends Road {
161
- static create(at_: string): Promise<File>;
161
+ /**
162
+ * Creates a new file at the specified path if it does not already exist.
163
+ *
164
+ * @param at_ The path at which to create the file.
165
+ * @returns A promise that resolves to the newly created `File` instance.
166
+ * @throws if {@link fp.writeFile} throws.
167
+ */
168
+ static create(at_: string, data?: string | Buffer): Promise<File>;
169
+ /** Alias for {@link File.create}. */
162
170
  static readonly mk: typeof File.create;
163
- static createSync(at_: string): File;
171
+ /** Synchronous version of {@link File.create}. */
172
+ static createSync(at_: string, data?: string | Buffer): File;
173
+ /** Alias for {@link File.createSync}. */
164
174
  static readonly mkSync: typeof File.createSync;
175
+ /** The file extension of this file, including the leading dot. */
165
176
  get ext(): string;
177
+ /** The file name without its extension. */
166
178
  get noExt(): string;
179
+ /**
180
+ * Reads the contents of the file.
181
+ *
182
+ * @returns A promise that resolves to the contents of the file as a `Buffer` or `string`, depending on the specified encoding.
183
+ * @throws If the file can't be read due to permission issues or other filesystem errors.
184
+ */
167
185
  read(): Promise<Buffer>;
168
- read(encoding_: BufferEncoding, flag_?: string): Promise<string>;
186
+ read(options_: Parameters<typeof fp.readFile>[1]): Promise<string>;
169
187
  readSync(): Buffer;
170
- readSync(encoding_: BufferEncoding, flag_?: string): string;
171
- itBuff(chunkSize_?: number, flags_?: string | number, mode_?: fs.Mode): AsyncGenerator<Buffer<ArrayBuffer>, void, unknown>;
172
- itBuffSync(chunkSize_?: number, flags_?: string | number, mode_?: fs.Mode): Generator<Buffer<ArrayBuffer>, void, unknown>;
188
+ readSync(options_: Parameters<typeof fs.readFileSync>[1]): string;
189
+ itBuff(options_?: fs.ReadStreamOptions): AsyncGenerator<Buffer>;
190
+ itBuffSync(chunkSize_?: number, flags_?: string | number, mode_?: fs.Mode): Generator<Buffer>;
191
+ sameAs(other_: File): Promise<boolean>;
192
+ sameAsSync(other_: File): boolean;
193
+ hash(algorithm_?: string, options_?: cr.HashOptions): Promise<Buffer>;
194
+ hash(algorithm_?: string, options_?: cr.HashOptions, encoding_?: BufferEncoding): Promise<string>;
195
+ hashSync(algorithm_?: string, options_?: cr.HashOptions): Buffer;
196
+ hashSync(algorithm_?: string, options_?: cr.HashOptions, encoding_?: BufferEncoding): string;
197
+ size(): Promise<number>;
198
+ sizeSync(): number;
199
+ writeAtomic(data_: Buffer | string, options_?: fs.WriteFileOptions): Promise<void>;
200
+ writeAtomicSync(data_: Buffer | string, options_?: fs.WriteFileOptions): void;
173
201
  write(data_: Buffer | string, options_?: fs.WriteFileOptions): Promise<void>;
174
202
  writeSync(data_: Buffer | string, options_?: fs.WriteFileOptions): void;
175
203
  append(data_: Buffer | string, options_?: fs.WriteFileOptions): Promise<void>;
176
204
  appendSync(data_: Buffer | string, options_?: fs.WriteFileOptions): void;
177
- delete(): Promise<void>;
178
- deleteSync(): void;
179
- move(into_: Folder): Promise<void>;
180
- moveSync(into_: Folder): void;
181
- copy(into_: Folder): Promise<this>;
182
- copySync(into_: Folder): this;
183
- rename(to_: string): Promise<void>;
184
- renameSync(to_: string): void;
185
205
  check(): Promise<boolean>;
186
206
  checkSync(): boolean;
187
207
  isFile(): this is File;
188
208
  }
189
- export declare function hash(f_: File, algorithm_?: string, options_?: cr.HashOptions): Promise<Buffer>;
190
- export declare function hash(f_: File, algorithm_?: string, options_?: cr.HashOptions, encoding_?: BufferEncoding): Promise<string>;
191
- export declare function hashSync(f_: File, algorithm_?: string, options_?: cr.HashOptions): Buffer;
192
- export declare function hashSync(f_: File, algorithm_?: string, options_?: cr.HashOptions, encoding_?: BufferEncoding): string;
193
- export declare function streamHash(f_: File, algorithm_?: string, options_?: cr.HashOptions): Promise<Buffer>;
194
- export declare function streamHash(f_: File, algorithm_?: string, options_?: cr.HashOptions, encoding_?: BufferEncoding): Promise<string>;
195
- export declare function streamHashSync(f_: File, algorithm_?: string, options_?: cr.HashOptions): Buffer;
196
- export declare function streamHashSync(f_: File, algorithm_?: string, options_?: cr.HashOptions, encoding_?: BufferEncoding): string;
197
- export declare function itLines(f_: File, options_?: fs.ReadStreamOptions): AsyncGenerator<string, void, unknown>;
198
- export declare function fileSameAs(f1_: File, f2_: File): Promise<boolean>;
199
- export declare function fileSameAsSync(f1_: File, f2_: File): boolean;
209
+ /** Helper type for filtering {@link Road} instances. */
210
+ export type filter_t<T extends Road> = ((road: Road) => road is T);
200
211
  export declare class Folder extends Road {
201
212
  static create(at_: string): Promise<Folder>;
202
213
  static readonly mk: typeof Folder.create;
@@ -204,38 +215,42 @@ export declare class Folder extends Road {
204
215
  static readonly mkSync: typeof Folder.createSync;
205
216
  join(...paths_: string[]): string;
206
217
  it(): AsyncIterable<Road>;
207
- it<T extends Road>(expectedType_: new (..._: any[]) => T): AsyncIterable<T>;
218
+ it<T extends Road>(filter_: filter_t<T>): AsyncIterable<T>;
208
219
  itSync(): Iterable<Road>;
209
- itSync<T extends Road>(expectedType_: new (..._: any[]) => T): Iterable<T>;
220
+ itSync<T extends Road>(filter_: filter_t<T>): Iterable<T>;
210
221
  list(): Promise<Road[]>;
211
- list<T extends Road>(expectedType_: new (..._: any[]) => T): Promise<T[]>;
222
+ list<T extends Road>(filter_: filter_t<T>): Promise<T[]>;
212
223
  listSync(): Road[];
213
- listSync<T extends Road>(expectedType_: new (..._: any[]) => T): T[];
224
+ listSync<T extends Road>(filter_: filter_t<T>): T[];
225
+ walk(): AsyncIterable<Road>;
226
+ walk<T extends Road>(filter_: filter_t<T>): AsyncIterable<T>;
227
+ walk(filter_: (r: Road) => boolean): AsyncIterable<Road>;
228
+ walkSync(): Iterable<Road>;
229
+ walkSync<T extends Road>(filter_: filter_t<T>): Iterable<T>;
230
+ walkSync(filter_: (r: Road) => boolean): Iterable<Road>;
214
231
  find(name_: string): Promise<Road | null>;
215
- find<T extends Road>(name_: string, expectedType_: new (..._: any[]) => T): Promise<T | null>;
232
+ find<T extends Road>(name_: string, expect_: road_t<T>): Promise<T | null>;
216
233
  findSync(name_: string): Road | null;
217
- findSync<T extends Road>(name_: string, expectedType_: new (..._: any[]) => T): T | null;
234
+ findSync<T extends Road>(name_: string, expect_: road_t<T>): T | null;
218
235
  add<T extends Road>(name_: string, createable_: {
219
- create: (at: string) => Promise<T>;
236
+ mk: (at: string) => Promise<T>;
220
237
  }): Promise<T>;
221
238
  addSync<T extends Road>(name_: string, createable_: {
222
- createSync: (at: string) => T;
239
+ mkSync: (at: string) => T;
223
240
  }): T;
224
- delete(options_?: fs.RmOptions): Promise<void>;
225
- deleteSync(options_?: fs.RmOptions): void;
226
- move(into_: Folder): Promise<void>;
227
- moveSync(into_: Folder): void;
228
- copy(into_: Folder): Promise<this>;
229
- copySync(into_: Folder): this;
230
- rename(to_: string): Promise<void>;
231
- renameSync(to_: string): void;
241
+ borrow<T extends Road>(createable_: {
242
+ mk: (at: string) => Promise<T>;
243
+ }, cb_: (r: T) => Promise<void> | void): Promise<void>;
244
+ borrowSync<T extends Road>(createable_: {
245
+ mkSync: (at: string) => T;
246
+ }, cb_: (r: T) => void): void;
247
+ size(): Promise<number>;
248
+ sizeSync(): number;
232
249
  check(): Promise<boolean>;
233
250
  checkSync(): boolean;
234
251
  isFolder(): this is Folder;
235
252
  isDir(): this is Folder;
236
253
  isDirectory(): this is Folder;
237
- isDict(): this is Folder;
238
- isDictionary(): this is Folder;
239
254
  }
240
255
  export declare function sysRoot(): Folder;
241
256
  export declare function home(): Folder;
@@ -251,14 +266,10 @@ export declare class SymbolicLink extends Road {
251
266
  targetSync(): BlockDevice | CharacterDevice | Fifo | File | Folder | Socket | SymbolicLink;
252
267
  retarget(to_: Road): Promise<void>;
253
268
  retargetSync(to_: Road): void;
269
+ size(): Promise<number>;
270
+ sizeSync(): number;
254
271
  delete(): Promise<void>;
255
272
  deleteSync(): void;
256
- move(into_: Folder): Promise<void>;
257
- moveSync(into_: Folder): void;
258
- copy(into_: Folder): Promise<this>;
259
- copySync(into_: Folder): this;
260
- rename(to_: string): Promise<void>;
261
- renameSync(to_: string): void;
262
273
  check(): Promise<boolean>;
263
274
  checkSync(): boolean;
264
275
  isSymlink(): this is SymbolicLink;
@@ -267,17 +278,28 @@ export declare class SymbolicLink extends Road {
267
278
  export { SymbolicLink as Symlink };
268
279
  export declare abstract class UnusableRoad extends Road {
269
280
  readonly mutable: boolean;
270
- constructor(...args_: ConstructorParameters<typeof Road>);
281
+ size(): Promise<0>;
282
+ sizeSync(): 0;
271
283
  error(): never;
272
- lock(): Promise<never>;
284
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be locked */
285
+ lock(): never;
286
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be locked */
273
287
  lockSync(): never;
274
- delete(): Promise<never>;
288
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be deleted */
289
+ delete(): never;
290
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be deleted */
275
291
  deleteSync(): never;
276
- move(): Promise<never>;
292
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be moved */
293
+ move(): never;
294
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be moved */
277
295
  moveSync(): never;
278
- copy(): Promise<never>;
296
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be copied */
297
+ copy(): never;
298
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be copied */
279
299
  copySync(): never;
280
- rename(): Promise<never>;
300
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be renamed */
301
+ rename(): never;
302
+ /** @deprecated System-level resources (UnusableRoad) can't/shouldn't be renamed */
281
303
  renameSync(): never;
282
304
  isUnusable(): this is UnusableRoad;
283
305
  }
@@ -301,8 +323,4 @@ export declare class Socket extends UnusableRoad {
301
323
  checkSync(): boolean;
302
324
  isSocket(): this is Socket;
303
325
  }
304
- export declare function registerToCleanup(self_: Road): void;
305
- export declare function Temp<T extends Road>(createable_: {
306
- createSync: (at: string) => T;
307
- }, autoCleanup_: boolean): T & Disposable & AsyncDisposable;
308
326
  //# sourceMappingURL=road.d.ts.map