@wtasnorg/node-lib 0.0.9 → 0.0.10

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.
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **createFindDirectories**(`deps`): (`root`, `options`) => `Promise`\<`string`[]\>
10
10
 
11
- Defined in: [find.ts:19](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/find.ts#L19)
11
+ Defined in: [find.ts:19](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/find.ts#L19)
12
12
 
13
13
  Factory that produces an async findDirectories function with
14
14
  injected filesystem dependencies for full testability.
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **decode**(`input`, `charset`): `string`
10
10
 
11
- Defined in: base64.ts:119
11
+ Defined in: [base64.ts:119](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/base64.ts#L119)
12
12
 
13
13
  Decode a Base64 string.
14
14
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **encode**(`input`, `charset`): `string`
10
10
 
11
- Defined in: base64.ts:79
11
+ Defined in: [base64.ts:79](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/base64.ts#L79)
12
12
 
13
13
  Encode a string to Base64.
14
14
 
@@ -6,14 +6,46 @@
6
6
 
7
7
  # Function: hello()
8
8
 
9
- > **hello**(): `Promise`\<`string`\>
9
+ > **hello**(`konsole?`): `Promise`\<`string`\>
10
10
 
11
- Defined in: [hello.ts:6](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/hello.ts#L6)
11
+ Defined in: [hello.ts:31](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/hello.ts#L31)
12
12
 
13
13
  A sample function that should work to test if lib is installed correctly.
14
14
 
15
+ ## Parameters
16
+
17
+ ### konsole?
18
+
19
+ `Console`
20
+
21
+ optional console object to log the message
22
+
15
23
  ## Returns
16
24
 
17
25
  `Promise`\<`string`\>
18
26
 
19
- hello message
27
+ `hello from @wtasnorg/node-lib`
28
+
29
+ ## Examples
30
+
31
+ ```ts
32
+ import { hello } from "@wtasnorg/node-lib";
33
+
34
+ async function main() {
35
+ const message = await hello(console);
36
+ console.log("Received message:", message);
37
+ }
38
+
39
+ main();
40
+ ```
41
+
42
+ ```ts
43
+ import { hello } from "@wtasnorg/node-lib";
44
+
45
+ async function main() {
46
+ const message = await hello();
47
+ // Do something with the message
48
+ }
49
+
50
+ main();
51
+ ```
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **parseUserAgent**(`ua`): [`UserAgentInfo`](../interfaces/UserAgentInfo.md)
10
10
 
11
- Defined in: [user-agent.ts:48](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/user-agent.ts#L48)
11
+ Defined in: [user-agent.ts:48](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/user-agent.ts#L48)
12
12
 
13
13
  Parses a user-agent string into a UserAgentInfo object.
14
14
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **pojo**\<`T`\>(`instance`): `Record`\<`string`, `unknown`\>
10
10
 
11
- Defined in: [pojo.ts:10](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/pojo.ts#L10)
11
+ Defined in: [pojo.ts:10](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/pojo.ts#L10)
12
12
 
13
13
  Convert a class instance into a plain JavaScript object.
14
14
  Copies only the instance's own enumerable data properties
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Interface: FileSystemDependencies
8
8
 
9
- Defined in: [find.ts:3](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/find.ts#L3)
9
+ Defined in: [find.ts:3](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/find.ts#L3)
10
10
 
11
11
  ## Properties
12
12
 
@@ -14,7 +14,7 @@ Defined in: [find.ts:3](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bd
14
14
 
15
15
  > **readdir**: (`_path`, `_opts`) => `Promise`\<`object`[]\>
16
16
 
17
- Defined in: [find.ts:4](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/find.ts#L4)
17
+ Defined in: [find.ts:4](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/find.ts#L4)
18
18
 
19
19
  #### Parameters
20
20
 
@@ -38,7 +38,7 @@ Defined in: [find.ts:4](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bd
38
38
 
39
39
  > **stat**: (`_path`) => `Promise`\<\{ `isDirectory`: `boolean`; \}\>
40
40
 
41
- Defined in: [find.ts:5](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/find.ts#L5)
41
+ Defined in: [find.ts:5](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/find.ts#L5)
42
42
 
43
43
  #### Parameters
44
44
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Interface: FindDirectoriesOptions
8
8
 
9
- Defined in: [find.ts:8](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/find.ts#L8)
9
+ Defined in: [find.ts:8](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/find.ts#L8)
10
10
 
11
11
  ## Properties
12
12
 
@@ -14,7 +14,7 @@ Defined in: [find.ts:8](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bd
14
14
 
15
15
  > `optional` **allowlist**: `string`[] \| (`_absPath`, `_name`) => `boolean`
16
16
 
17
- Defined in: [find.ts:11](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/find.ts#L11)
17
+ Defined in: [find.ts:11](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/find.ts#L11)
18
18
 
19
19
  ***
20
20
 
@@ -22,7 +22,7 @@ Defined in: [find.ts:11](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1b
22
22
 
23
23
  > `optional` **blocklist**: `string`[] \| (`_absPath`, `_name`) => `boolean`
24
24
 
25
- Defined in: [find.ts:12](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/find.ts#L12)
25
+ Defined in: [find.ts:12](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/find.ts#L12)
26
26
 
27
27
  ***
28
28
 
@@ -30,7 +30,7 @@ Defined in: [find.ts:12](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1b
30
30
 
31
31
  > `optional` **followSymlinks**: `boolean`
32
32
 
33
- Defined in: [find.ts:10](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/find.ts#L10)
33
+ Defined in: [find.ts:10](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/find.ts#L10)
34
34
 
35
35
  ***
36
36
 
@@ -38,4 +38,4 @@ Defined in: [find.ts:10](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1b
38
38
 
39
39
  > `optional` **maxDepth**: `number`
40
40
 
41
- Defined in: [find.ts:9](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/find.ts#L9)
41
+ Defined in: [find.ts:9](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/find.ts#L9)
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Interface: UserAgentInfo
8
8
 
9
- Defined in: [user-agent.ts:4](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/user-agent.ts#L4)
9
+ Defined in: [user-agent.ts:4](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/user-agent.ts#L4)
10
10
 
11
11
  Information extracted from a user-agent string.
12
12
 
@@ -16,7 +16,7 @@ Information extracted from a user-agent string.
16
16
 
17
17
  > **browser**: `string`
18
18
 
19
- Defined in: [user-agent.ts:8](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/user-agent.ts#L8)
19
+ Defined in: [user-agent.ts:8](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/user-agent.ts#L8)
20
20
 
21
21
  Browser name (e.g., Chrome, Firefox, Safari, Edge, Opera, Other).
22
22
 
@@ -26,7 +26,7 @@ Browser name (e.g., Chrome, Firefox, Safari, Edge, Opera, Other).
26
26
 
27
27
  > **device**: `string`
28
28
 
29
- Defined in: [user-agent.ts:20](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/user-agent.ts#L20)
29
+ Defined in: [user-agent.ts:20](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/user-agent.ts#L20)
30
30
 
31
31
  Device type (e.g., Mobile, Tablet, Desktop, Other).
32
32
 
@@ -36,7 +36,7 @@ Device type (e.g., Mobile, Tablet, Desktop, Other).
36
36
 
37
37
  > **engine**: `string`
38
38
 
39
- Defined in: [user-agent.ts:24](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/user-agent.ts#L24)
39
+ Defined in: [user-agent.ts:24](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/user-agent.ts#L24)
40
40
 
41
41
  Rendering engine (e.g., Blink, WebKit, Gecko, Presto, Other).
42
42
 
@@ -46,7 +46,7 @@ Rendering engine (e.g., Blink, WebKit, Gecko, Presto, Other).
46
46
 
47
47
  > **os**: `string`
48
48
 
49
- Defined in: [user-agent.ts:16](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/user-agent.ts#L16)
49
+ Defined in: [user-agent.ts:16](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/user-agent.ts#L16)
50
50
 
51
51
  Operating system (e.g., Windows, macOS, Linux, iOS, Android, Other).
52
52
 
@@ -56,6 +56,6 @@ Operating system (e.g., Windows, macOS, Linux, iOS, Android, Other).
56
56
 
57
57
  > **version**: `string`
58
58
 
59
- Defined in: [user-agent.ts:12](https://github.com/wtasg/node-lib/blob/b5efd5c345e8fa1bdc2a6d3ea4dd4b2eb5b9cc62/src/user-agent.ts#L12)
59
+ Defined in: [user-agent.ts:12](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/user-agent.ts#L12)
60
60
 
61
61
  Browser version (e.g., 120.0.0.0).
@@ -8,6 +8,6 @@
8
8
 
9
9
  > **Base64CharsetType** = *typeof* [`Base64Charset`](../variables/Base64Charset.md)\[`number`\]
10
10
 
11
- Defined in: base64.ts:18
11
+ Defined in: [base64.ts:18](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/base64.ts#L18)
12
12
 
13
13
  Base64 charset type.
@@ -8,7 +8,7 @@
8
8
 
9
9
  > `const` **Base64Charset**: readonly \[`"standard"`, `"urlsafe"`, `"imap"`, `"radix64"`\]
10
10
 
11
- Defined in: base64.ts:13
11
+ Defined in: [base64.ts:13](https://github.com/wtasg/node-lib/blob/7baf8669b7042dca550ec8a4beb26526d3b538b4/src/base64.ts#L13)
12
12
 
13
13
  Available Base64 charset variants.
14
14
  - `standard`: RFC 4648 standard alphabet (A-Z, a-z, 0-9, +, /)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtasnorg/node-lib",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "node library",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -38,5 +38,6 @@
38
38
  "typedoc-plugin-markdown": "^4.9.0",
39
39
  "typescript": "^5.9.3",
40
40
  "typescript-eslint": "^8.48.1"
41
- }
42
- }
41
+ },
42
+ "sideEffects": false
43
+ }
package/src/hello.d.ts CHANGED
@@ -1,8 +1,33 @@
1
1
  /**
2
2
  * A sample function that should work to test if lib is installed correctly.
3
3
  *
4
- * @returns hello message
4
+ * @param {Console?} konsole - optional console object to log the message
5
+ * @returns {Promise<string>} `hello from @wtasnorg/node-lib`
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { hello } from "@wtasnorg/node-lib";
10
+ *
11
+ * async function main() {
12
+ * const message = await hello(console);
13
+ * console.log("Received message:", message);
14
+ * }
15
+ *
16
+ * main();
17
+ * ```
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { hello } from "@wtasnorg/node-lib";
22
+ *
23
+ * async function main() {
24
+ * const message = await hello();
25
+ * // Do something with the message
26
+ * }
27
+ *
28
+ * main();
29
+ * ```
5
30
  */
6
- declare function hello(): Promise<string>;
31
+ declare function hello(konsole?: Console): Promise<string>;
7
32
  export { hello };
8
33
  //# sourceMappingURL=hello.d.ts.map
package/src/hello.js CHANGED
@@ -1,12 +1,37 @@
1
1
  /**
2
2
  * A sample function that should work to test if lib is installed correctly.
3
3
  *
4
- * @returns hello message
4
+ * @param {Console?} konsole - optional console object to log the message
5
+ * @returns {Promise<string>} `hello from @wtasnorg/node-lib`
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { hello } from "@wtasnorg/node-lib";
10
+ *
11
+ * async function main() {
12
+ * const message = await hello(console);
13
+ * console.log("Received message:", message);
14
+ * }
15
+ *
16
+ * main();
17
+ * ```
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { hello } from "@wtasnorg/node-lib";
22
+ *
23
+ * async function main() {
24
+ * const message = await hello();
25
+ * // Do something with the message
26
+ * }
27
+ *
28
+ * main();
29
+ * ```
5
30
  */
6
- async function hello() {
31
+ async function hello(konsole) {
7
32
  const message = "hello from @wtasnorg/node-lib";
8
- if (console?.log) {
9
- console.log(message);
33
+ if (konsole?.log) {
34
+ konsole.log(message);
10
35
  }
11
36
  return message;
12
37
  }
package/src/hello.test.js CHANGED
@@ -12,5 +12,16 @@ describe("hello", () => {
12
12
  const actual = await hello();
13
13
  strictEqual(actual, expected);
14
14
  });
15
+ it("logs message when console is provided", async () => {
16
+ const spyConsole = {
17
+ logCalledWith: "",
18
+ log(message) {
19
+ this.logCalledWith = message;
20
+ }
21
+ };
22
+ const expectedMessage = "hello from @wtasnorg/node-lib";
23
+ await hello(spyConsole);
24
+ strictEqual(spyConsole.logCalledWith, expectedMessage);
25
+ });
15
26
  });
16
27
  //# sourceMappingURL=hello.test.js.map
package/src/hello.test.ts CHANGED
@@ -14,4 +14,17 @@ describe("hello", () => {
14
14
  const actual = await hello();
15
15
  strictEqual(actual, expected);
16
16
  });
17
+
18
+ it("logs message when console is provided", async () => {
19
+ const spyConsole = {
20
+ logCalledWith: "",
21
+ log(message: string) {
22
+ this.logCalledWith = message;
23
+ }
24
+ };
25
+
26
+ const expectedMessage = "hello from @wtasnorg/node-lib";
27
+ await hello(spyConsole as unknown as Console);
28
+ strictEqual(spyConsole.logCalledWith, expectedMessage);
29
+ });
17
30
  });
package/src/hello.ts CHANGED
@@ -1,12 +1,37 @@
1
1
  /**
2
2
  * A sample function that should work to test if lib is installed correctly.
3
3
  *
4
- * @returns hello message
4
+ * @param {Console?} konsole - optional console object to log the message
5
+ * @returns {Promise<string>} `hello from @wtasnorg/node-lib`
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { hello } from "@wtasnorg/node-lib";
10
+ *
11
+ * async function main() {
12
+ * const message = await hello(console);
13
+ * console.log("Received message:", message);
14
+ * }
15
+ *
16
+ * main();
17
+ * ```
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { hello } from "@wtasnorg/node-lib";
22
+ *
23
+ * async function main() {
24
+ * const message = await hello();
25
+ * // Do something with the message
26
+ * }
27
+ *
28
+ * main();
29
+ * ```
5
30
  */
6
- async function hello() {
31
+ async function hello(konsole?: Console): Promise<string> {
7
32
  const message = "hello from @wtasnorg/node-lib";
8
- if (console?.log) {
9
- console.log(message);
33
+ if (konsole?.log) {
34
+ konsole.log(message);
10
35
  }
11
36
  return message;
12
37
  }