@ucdjs/utils 0.1.0 → 0.2.1-beta.2

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
@@ -2,8 +2,9 @@
2
2
 
3
3
  [![npm version][npm-version-src]][npm-version-href]
4
4
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![codecov][codecov-src]][codecov-href]
5
6
 
6
- Utilities for working with the Unicode Character Database (UCD).
7
+ A collection of utility functions and filesystem bridge implementations for the UCD project.
7
8
 
8
9
  ## Installation
9
10
 
@@ -11,6 +12,57 @@ Utilities for working with the Unicode Character Database (UCD).
11
12
  npm install @ucdjs/utils
12
13
  ```
13
14
 
15
+ ## Usage
16
+
17
+ ### Path Filtering
18
+
19
+ Creates a filter function that checks if a file path should be included or excluded based on glob patterns.
20
+
21
+ ```typescript
22
+ import { createPathFilter } from "@ucdjs/utils";
23
+
24
+ const filter = createPathFilter(["*.txt", "!*Test*"]);
25
+ filter("Data.txt"); // true
26
+ filter("DataTest.txt"); // false
27
+ ```
28
+
29
+ #### PathFilter Methods
30
+
31
+ The `PathFilter` object provides additional methods:
32
+
33
+ ```typescript
34
+ const filter = createPathFilter(["*.js"]);
35
+
36
+ // Extend with additional patterns
37
+ filter.extend(["*.ts", "!*.test.*"]);
38
+
39
+ // Get current patterns
40
+ const patterns = filter.patterns(); // ['*.js', '*.ts', '!*.test.*']
41
+
42
+ // Use with extra filters temporarily
43
+ filter("app.js", ["!src/**"]); // Apply extra exclusions
44
+ ```
45
+
46
+ ### Preconfigured Filters
47
+
48
+ Pre-defined filter patterns for common exclusions:
49
+
50
+ ```typescript
51
+ import { createPathFilter, PRECONFIGURED_FILTERS } from "@ucdjs/utils";
52
+
53
+ const filter = createPathFilter([
54
+ "*.txt",
55
+ PRECONFIGURED_FILTERS.EXCLUDE_TEST_FILES,
56
+ PRECONFIGURED_FILTERS.EXCLUDE_README_FILES,
57
+ PRECONFIGURED_FILTERS.EXCLUDE_HTML_FILES
58
+ ]);
59
+ ```
60
+
61
+ Available filters:
62
+ - `EXCLUDE_TEST_FILES`: Excludes files containing "Test" in their name
63
+ - `EXCLUDE_README_FILES`: Excludes ReadMe.txt files
64
+ - `EXCLUDE_HTML_FILES`: Excludes all HTML files
65
+
14
66
  ## 📄 License
15
67
 
16
68
  Published under [MIT License](./LICENSE).
@@ -19,3 +71,5 @@ Published under [MIT License](./LICENSE).
19
71
  [npm-version-href]: https://npmjs.com/package/@ucdjs/utils
20
72
  [npm-downloads-src]: https://img.shields.io/npm/dm/@ucdjs/utils?style=flat&colorA=18181B&colorB=4169E1
21
73
  [npm-downloads-href]: https://npmjs.com/package/@ucdjs/utils
74
+ [codecov-src]: https://img.shields.io/codecov/c/gh/ucdjs/ucd?style=flat&colorA=18181B&colorB=4169E1
75
+ [codecov-href]: https://codecov.io/gh/ucdjs/ucd
@@ -0,0 +1,6 @@
1
+ import { PRECONFIGURED_FILTERS, PathFilter, PathFilterOptions, createPathFilter, filterTreeStructure } from "@ucdjs-internal/shared";
2
+
3
+ //#region src/index.d.ts
4
+ declare function internal_bingbong(): void;
5
+ //#endregion
6
+ export { PRECONFIGURED_FILTERS, type PathFilter, type PathFilterOptions, createPathFilter, filterTreeStructure, internal_bingbong };
package/dist/index.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import { PRECONFIGURED_FILTERS, createPathFilter, filterTreeStructure } from "@ucdjs-internal/shared";
2
+
3
+ //#region src/index.ts
4
+ function internal_bingbong() {
5
+ console.log("Bing Bong");
6
+ }
7
+
8
+ //#endregion
9
+ export { PRECONFIGURED_FILTERS, createPathFilter, filterTreeStructure, internal_bingbong };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucdjs/utils",
3
- "version": "0.1.0",
3
+ "version": "0.2.1-beta.2",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Lucas Nørgård",
@@ -18,31 +18,37 @@
18
18
  "url": "https://github.com/ucdjs/ucd/issues"
19
19
  },
20
20
  "exports": {
21
- ".": "./dist/index.js",
21
+ ".": "./dist/index.mjs",
22
22
  "./package.json": "./package.json"
23
23
  },
24
- "main": "./dist/index.js",
25
- "module": "./dist/index.js",
26
- "types": "./dist/index.d.ts",
24
+ "types": "./dist/index.d.mts",
27
25
  "files": [
28
26
  "dist"
29
27
  ],
28
+ "engines": {
29
+ "node": ">=22.18"
30
+ },
31
+ "dependencies": {
32
+ "@ucdjs-internal/shared": "0.1.1-beta.2"
33
+ },
30
34
  "devDependencies": {
31
- "@luxass/eslint-config": "^4.18.1",
32
- "eslint": "^9.27.0",
33
- "publint": "^0.3.12",
34
- "tsdown": "^0.12.5",
35
- "typescript": "^5.8.3",
36
- "vitest-testdirs": "^4.0.0"
35
+ "@luxass/eslint-config": "7.2.0",
36
+ "eslint": "10.0.0",
37
+ "publint": "0.3.17",
38
+ "tsdown": "0.20.3",
39
+ "typescript": "5.9.3",
40
+ "vitest-testdirs": "4.4.2",
41
+ "@ucdjs-tooling/tsconfig": "1.0.0",
42
+ "@ucdjs-tooling/tsdown-config": "1.0.0"
37
43
  },
38
44
  "publishConfig": {
39
45
  "access": "public"
40
46
  },
41
47
  "scripts": {
42
- "build": "tsdown",
48
+ "build": "tsdown --tsconfig=./tsconfig.build.json",
43
49
  "dev": "tsdown --watch",
44
50
  "clean": "git clean -xdf dist node_modules",
45
51
  "lint": "eslint .",
46
- "typecheck": "tsc --noEmit"
52
+ "typecheck": "tsc --noEmit -p tsconfig.build.json"
47
53
  }
48
54
  }
package/dist/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- //#region src/index.d.ts
2
- /**
3
- * Safely parses a JSON string into an object of type T.
4
- * Returns null if the parsing fails.
5
- *
6
- * @template T - The expected type of the parsed JSON
7
- * @param {string} content - The JSON string to parse
8
- * @returns {T | null} The parsed object of type T or null if parsing fails
9
- */
10
- declare function safeJsonParse<T>(content: string): T | null;
11
- //#endregion
12
- export { safeJsonParse };
package/dist/index.js DELETED
@@ -1,20 +0,0 @@
1
- //#region src/index.ts
2
- /**
3
- * Safely parses a JSON string into an object of type T.
4
- * Returns null if the parsing fails.
5
- *
6
- * @template T - The expected type of the parsed JSON
7
- * @param {string} content - The JSON string to parse
8
- * @returns {T | null} The parsed object of type T or null if parsing fails
9
- */
10
- function safeJsonParse(content) {
11
- try {
12
- return JSON.parse(content);
13
- } catch (err) {
14
- console.error("[safeJsonParse] Failed to parse JSON:", err);
15
- return null;
16
- }
17
- }
18
-
19
- //#endregion
20
- export { safeJsonParse };