@wtasnorg/node-lib 0.0.6 → 0.0.7

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/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/find.ts#L19)
11
+ Defined in: [find.ts:19](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/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
  > **hello**(): `Promise`\<`string`\>
10
10
 
11
- Defined in: [hello.ts:6](https://github.com/wtasg/node-lib/blob/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/hello.ts#L6)
11
+ Defined in: [hello.ts:6](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/src/hello.ts#L6)
12
12
 
13
13
  A sample function that should work to test if lib is installed correctly.
14
14
 
@@ -6,9 +6,9 @@
6
6
 
7
7
  # Function: pojo()
8
8
 
9
- > **pojo**\<`T`\>(`instance`): `Record`\<`string`, `any`\>
9
+ > **pojo**\<`T`\>(`instance`): `Record`\<`string`, `unknown`\>
10
10
 
11
- Defined in: [pojo.ts:10](https://github.com/wtasg/node-lib/blob/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/pojo.ts#L10)
11
+ Defined in: [pojo.ts:10](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/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
@@ -30,6 +30,6 @@ A class instance to convert.
30
30
 
31
31
  ## Returns
32
32
 
33
- `Record`\<`string`, `any`\>
33
+ `Record`\<`string`, `unknown`\>
34
34
 
35
35
  A plain JavaScript object containing only data fields.
@@ -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/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/find.ts#L3)
9
+ Defined in: [find.ts:3](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/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/01d2e57d5a7dbc345
14
14
 
15
15
  > **readdir**: (`path`, `opts`) => `Promise`\<`object`[]\>
16
16
 
17
- Defined in: [find.ts:4](https://github.com/wtasg/node-lib/blob/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/find.ts#L4)
17
+ Defined in: [find.ts:4](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/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/01d2e57d5a7dbc345
38
38
 
39
39
  > **stat**: (`path`) => `Promise`\<\{ `isDirectory`: `boolean`; \}\>
40
40
 
41
- Defined in: [find.ts:5](https://github.com/wtasg/node-lib/blob/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/find.ts#L5)
41
+ Defined in: [find.ts:5](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/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/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/find.ts#L8)
9
+ Defined in: [find.ts:8](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/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/01d2e57d5a7dbc345
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/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/find.ts#L11)
17
+ Defined in: [find.ts:11](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/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/01d2e57d5a7dbc34
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/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/find.ts#L12)
25
+ Defined in: [find.ts:12](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/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/01d2e57d5a7dbc34
30
30
 
31
31
  > `optional` **followSymlinks**: `boolean`
32
32
 
33
- Defined in: [find.ts:10](https://github.com/wtasg/node-lib/blob/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/find.ts#L10)
33
+ Defined in: [find.ts:10](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/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/01d2e57d5a7dbc34
38
38
 
39
39
  > `optional` **maxDepth**: `number`
40
40
 
41
- Defined in: [find.ts:9](https://github.com/wtasg/node-lib/blob/01d2e57d5a7dbc3451098355b40ab686f5320efe/src/find.ts#L9)
41
+ Defined in: [find.ts:9](https://github.com/wtasg/node-lib/blob/5ccb6028429af225c9ab29e1b6007075025c601f/src/find.ts#L9)
@@ -0,0 +1,47 @@
1
+ // @ts-check
2
+
3
+ import eslint from "@eslint/js";
4
+ import { defineConfig } from "eslint/config";
5
+ import tseslint from "typescript-eslint";
6
+ import prettier from "eslint-config-prettier";
7
+ import globals from "globals";
8
+ import stylistic from "@stylistic/eslint-plugin";
9
+
10
+ export default defineConfig([
11
+ eslint.configs.recommended,
12
+ ...tseslint.configs.recommended,
13
+ ...tseslint.configs.strict,
14
+ ...tseslint.configs.stylistic,
15
+ prettier,
16
+
17
+ {
18
+ languageOptions: {
19
+ globals: {
20
+ ...globals.node,
21
+ }
22
+ }
23
+ },
24
+
25
+ {
26
+ plugins: {
27
+ "@stylistic": stylistic
28
+ }
29
+ },
30
+
31
+ {
32
+ rules: {
33
+ "@typescript-eslint/no-unused-vars": [
34
+ "warn",
35
+ {
36
+ argsIgnorePattern: "^_",
37
+ varsIgnorePattern: "^_",
38
+ caughtErrorsIgnorePattern: "^_"
39
+ }
40
+ ],
41
+
42
+ semi: ["error", "always"],
43
+ // "no-unused-vars": ["error", { varsIgnorePattern: "^[A-Z_]" }],
44
+ "@stylistic/quotes": ["error", "double"]
45
+ }
46
+ }
47
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtasnorg/node-lib",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "node library",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -27,9 +27,15 @@
27
27
  "url": "git+https://github.com/wtasg/node-lib.git"
28
28
  },
29
29
  "devDependencies": {
30
+ "@eslint/js": "^9.39.1",
31
+ "@stylistic/eslint-plugin": "^5.6.1",
30
32
  "@types/node": "^24.10.1",
33
+ "eslint": "^9.39.1",
34
+ "eslint-config-prettier": "^10.1.8",
35
+ "globals": "^16.5.0",
31
36
  "typedoc": "^0.28.15",
32
37
  "typedoc-plugin-markdown": "^4.9.0",
33
- "typescript": "^5.9.3"
38
+ "typescript": "^5.9.3",
39
+ "typescript-eslint": "^8.48.1"
34
40
  }
35
41
  }
package/src/find.js CHANGED
@@ -39,7 +39,7 @@ function createFindDirectories(deps) {
39
39
  const entries = await readdir(currentPath, { withFileTypes: true });
40
40
  for (const entry of entries) {
41
41
  const childPath = resolve(join(currentPath, entry.name));
42
- let isDirectory = entry.isDirectory();
42
+ const isDirectory = entry.isDirectory();
43
43
  if (!isDirectory)
44
44
  continue;
45
45
  if (isBlocked(childPath, entry.name))
package/src/find.test.js CHANGED
@@ -58,10 +58,8 @@ test("find: findDirectories symlink is NOT treated as a directory", async () =>
58
58
  ]);
59
59
  });
60
60
  test("find: findDirectories at depth=2", async () => {
61
- const calls = [];
62
61
  const deps = {
63
62
  readdir: async (path) => {
64
- calls.push(path);
65
63
  switch (path) {
66
64
  case "/root":
67
65
  return [dir("a"), dir("b"), file("ignore.txt")];
@@ -73,7 +71,7 @@ test("find: findDirectories at depth=2", async () => {
73
71
  return [];
74
72
  }
75
73
  },
76
- stat: async (_) => ({
74
+ stat: async () => ({
77
75
  isDirectory: () => false
78
76
  })
79
77
  };
@@ -88,10 +86,8 @@ test("find: findDirectories at depth=2", async () => {
88
86
  ].sort());
89
87
  });
90
88
  test("find: findDirectories at depth=3", async () => {
91
- const calls = [];
92
89
  const deps = {
93
90
  readdir: async (path) => {
94
- calls.push(path);
95
91
  switch (path) {
96
92
  case "/root":
97
93
  return [dir("a"), dir("b")];
@@ -108,7 +104,7 @@ test("find: findDirectories at depth=3", async () => {
108
104
  return [];
109
105
  }
110
106
  },
111
- stat: async (_) => ({
107
+ stat: async () => ({
112
108
  isDirectory: () => false
113
109
  })
114
110
  };
package/src/find.test.ts CHANGED
@@ -77,12 +77,8 @@ test("find: findDirectories symlink is NOT treated as a directory", async () =>
77
77
 
78
78
 
79
79
  test("find: findDirectories at depth=2", async () => {
80
- const calls: string[] = [];
81
-
82
80
  const deps: FileSystemDependencies = {
83
81
  readdir: async (path: string): Promise<{ name: string; isDirectory(): boolean }[]> => {
84
- calls.push(path);
85
-
86
82
  switch (path) {
87
83
  case "/root":
88
84
  return [dir("a"), dir("b"), file("ignore.txt")];
@@ -94,7 +90,7 @@ test("find: findDirectories at depth=2", async () => {
94
90
  return [];
95
91
  }
96
92
  },
97
- stat: async (_: string) => ({
93
+ stat: async () => ({
98
94
  isDirectory: () => false
99
95
  })
100
96
  };
@@ -113,12 +109,8 @@ test("find: findDirectories at depth=2", async () => {
113
109
  });
114
110
 
115
111
  test("find: findDirectories at depth=3", async () => {
116
- const calls: string[] = [];
117
-
118
112
  const deps: FileSystemDependencies = {
119
113
  readdir: async (path: string): Promise<{ name: string; isDirectory(): boolean }[]> => {
120
- calls.push(path);
121
-
122
114
  switch (path) {
123
115
  case "/root":
124
116
  return [dir("a"), dir("b")];
@@ -130,12 +122,12 @@ test("find: findDirectories at depth=3", async () => {
130
122
  case "/root/b/b1":
131
123
  return [dir("c")];
132
124
  case "/root/b/b1/c":
133
- return [dir("d"), file("fd")]
125
+ return [dir("d"), file("fd")];
134
126
  default:
135
127
  return [];
136
128
  }
137
129
  },
138
- stat: async (_: string) => ({
130
+ stat: async () => ({
139
131
  isDirectory: () => false
140
132
  })
141
133
  };
package/src/find.ts CHANGED
@@ -65,7 +65,7 @@ function createFindDirectories(deps: FileSystemDependencies) {
65
65
  for (const entry of entries) {
66
66
  const childPath = resolve(join(currentPath, entry.name));
67
67
 
68
- let isDirectory = entry.isDirectory();
68
+ const isDirectory = entry.isDirectory();
69
69
 
70
70
  if (!isDirectory) continue;
71
71
 
@@ -91,9 +91,9 @@ function createFindDirectories(deps: FileSystemDependencies) {
91
91
 
92
92
  export {
93
93
  createFindDirectories,
94
- }
94
+ };
95
95
 
96
96
  export type {
97
97
  FileSystemDependencies,
98
98
  FindDirectoriesOptions,
99
- }
99
+ };
package/src/index.ts CHANGED
@@ -12,4 +12,4 @@ export {
12
12
  export type {
13
13
  FindDirectoriesOptions,
14
14
  FileSystemDependencies,
15
- }
15
+ };
package/src/pojo.d.ts CHANGED
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * @template T
7
7
  * @param {T} instance - A class instance to convert.
8
- * @returns {Object<string, any>} A plain JavaScript object containing only data fields.
8
+ * @returns {Object<string, unknown>} A plain JavaScript object containing only data fields.
9
9
  */
10
- declare function pojo<T extends object>(instance: T): Record<string, any>;
10
+ declare function pojo<T extends object>(instance: T): Record<string, unknown>;
11
11
  export { pojo };
12
12
  //# sourceMappingURL=pojo.d.ts.map
package/src/pojo.js CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @template T
7
7
  * @param {T} instance - A class instance to convert.
8
- * @returns {Object<string, any>} A plain JavaScript object containing only data fields.
8
+ * @returns {Object<string, unknown>} A plain JavaScript object containing only data fields.
9
9
  */
10
10
  function pojo(instance) {
11
11
  return Object.fromEntries(Object.entries(instance).filter(([_, value]) => typeof value !== "function"));
package/src/pojo.ts CHANGED
@@ -5,9 +5,9 @@
5
5
  *
6
6
  * @template T
7
7
  * @param {T} instance - A class instance to convert.
8
- * @returns {Object<string, any>} A plain JavaScript object containing only data fields.
8
+ * @returns {Object<string, unknown>} A plain JavaScript object containing only data fields.
9
9
  */
10
- function pojo<T extends object>(instance: T): Record<string, any> {
10
+ function pojo<T extends object>(instance: T): Record<string, unknown> {
11
11
  return Object.fromEntries(
12
12
  Object.entries(instance).filter(([_, value]) => typeof value !== "function")
13
13
  );
package/test_report ADDED
@@ -0,0 +1,26 @@
1
+
2
+ > @wtasnorg/node-lib@0.0.7 test
3
+ > bash -c 'node --test src/**/*.test.js'
4
+
5
+ ✔ find: findDirectories success (1.077042ms)
6
+ ✔ find: findDirectories symlink is NOT treated as a directory (0.181028ms)
7
+ ✔ find: findDirectories at depth=2 (0.264408ms)
8
+ ✔ find: findDirectories at depth=3 (0.225558ms)
9
+ hello from @wtasnorg/node-lib
10
+ hello from @wtasnorg/node-lib
11
+ ▶ hello
12
+ ✔ returns a string that has the word 'hello' in it (0.855703ms)
13
+ ✔ returns exact string (0.132439ms)
14
+ ✔ hello (1.649597ms)
15
+ ✔ pojo() should return only enumerable data fields (0.948072ms)
16
+ ✔ pojo() should exclude methods (0.137609ms)
17
+ ✔ pojo() should exclude prototype properties (0.141089ms)
18
+ ✔ pojo() should ignore non-enumerable own properties (0.671565ms)
19
+ ℹ tests 10
20
+ ℹ suites 1
21
+ ℹ pass 10
22
+ ℹ fail 0
23
+ ℹ cancelled 0
24
+ ℹ skipped 0
25
+ ℹ todo 0
26
+ ℹ duration_ms 50.692585
package/typedoc.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "$schema": "https://typedoc.org/schema.json",
3
- "entryPoints": ["./src/index.ts"],
3
+ "entryPoints": [
4
+ "./src/index.ts"
5
+ ],
4
6
  "excludePrivate": true,
5
7
  "excludeProtected": true,
6
8
  "name": "@wtasnorg/node-lib",
7
9
  "out": "docs",
8
- "plugin": ["typedoc-plugin-markdown"],
10
+ "plugin": [
11
+ "typedoc-plugin-markdown"
12
+ ],
9
13
  "theme": "default",
10
14
  "tsconfig": "./tsconfig.json",
11
15
  }