@tkeron/tools 0.2.0 โ†’ 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tkeron/tools",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Useful JavaScript utilities for Bun runtime",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
package/readme.md CHANGED
@@ -1,3 +1,45 @@
1
- # Tkeron Tools
1
+ # @tkeron/tools
2
2
 
3
- Useful Javascript utilities
3
+ Useful JavaScript utilities for Bun runtime - A collection of lightweight, type-safe utilities designed specifically for the Bun environment.
4
+
5
+ ## ๐Ÿš€ Installation
6
+
7
+ ```bash
8
+ bun add @tkeron/tools
9
+ ```
10
+
11
+ ## ๐Ÿ“‹ Requirements
12
+
13
+ - **Bun** >= 1.0.0
14
+ - **TypeScript** ^5.7.3
15
+
16
+ ## ๐Ÿ“– About
17
+
18
+ This package provides a growing collection of utility functions and data structures optimized for the Bun runtime. All utilities are written in TypeScript with full type safety and are designed to be lightweight, performant, and easy to use.
19
+
20
+ ## ๐Ÿ”ง Usage
21
+
22
+ ```typescript
23
+ // Import all utilities
24
+ import * as tools from '@tkeron/tools';
25
+
26
+ // Or import specific utilities
27
+ import { rng, getLIFO, getPaths } from '@tkeron/tools';
28
+ ```
29
+
30
+ ## ๐Ÿ“š Documentation
31
+
32
+ For detailed documentation of all available utilities, please refer to the TypeScript definitions or explore the source code. Each utility is fully typed and includes JSDoc comments for better IDE support.
33
+
34
+ ## ๐Ÿงช Testing
35
+
36
+ The project includes comprehensive tests for all utilities:
37
+
38
+ ```bash
39
+ bun test
40
+ ```
41
+
42
+
43
+
44
+
45
+ Built with โค๏ธ for the Bun ecosystem
@@ -46,6 +46,10 @@ describe("getPaths Tests", () => {
46
46
  writeFileSync(join(testDir, "node_modules", "package.json"), "content");
47
47
  mkdirSync(join(testDir, "build"), { recursive: true });
48
48
  writeFileSync(join(testDir, "build", "output.js"), "content");
49
+
50
+ for (let i = 123; i <= 129; i++) {
51
+ mkdirSync(join(testDir, `build`, `qwerty_${i}.com`), { recursive: true });
52
+ }
49
53
  });
50
54
 
51
55
  afterAll(() => {
@@ -245,25 +249,24 @@ describe("getPaths Tests", () => {
245
249
  expect(files.some(path => path === ".env")).toBe(true);
246
250
  expect(files.some(path => path === "src/index.ts")).toBe(true);
247
251
  expect(files.some(path => path === "src/components/Button.tsx")).toBe(true);
248
-
252
+
249
253
  const nestedFiles = files.filter(path => path.includes("/"));
250
254
  expect(nestedFiles.length).toBeGreaterThan(0);
251
255
 
252
256
  expect(dirs.some(path => path === "src")).toBe(true);
253
257
  expect(dirs.some(path => path === ".git")).toBe(true);
254
-
258
+
255
259
  expect(dirs.length).toBeGreaterThan(0);
256
260
  });
257
261
 
258
262
  test("absolute parameter should work consistently across all function variants", () => {
259
263
  const pattern = "src/**";
260
264
 
261
- // Test with absolute = true
265
+
262
266
  const absoluteFiles = getFilePaths(testDir, pattern, true);
263
267
  const absoluteDirs = getDirectoryPaths(testDir, pattern, true);
264
268
  const absoluteAll = getPaths(testDir, pattern, "yes", true);
265
269
 
266
- // Test with absolute = false
267
270
  const relativeFiles = getFilePaths(testDir, pattern, false);
268
271
  const relativeDirs = getDirectoryPaths(testDir, pattern, false);
269
272
  const relativeAll = getPaths(testDir, pattern, "yes", false);
@@ -440,7 +443,6 @@ describe("getPaths Tests", () => {
440
443
  expect(files.some(path => path.includes("UPPERCASE.TXT"))).toBe(true);
441
444
  expect(files.some(path => path.includes("file1.txt"))).toBe(true);
442
445
 
443
- // Should be case sensitive
444
446
  const upper = getFilePaths(testDir, "*UPPER*");
445
447
  const lower = getFilePaths(testDir, "*upper*");
446
448
  expect(upper.length).toBeGreaterThan(0);
@@ -483,9 +485,28 @@ describe("getPaths Tests", () => {
483
485
  expect(dir).toMatch(/^[\/\\]|^[a-zA-Z]:[\/\\]/);
484
486
  });
485
487
  });
488
+
489
+
490
+
491
+ test("should return the same number of paths with absolute false or true", () => {
492
+
493
+ const absolutes = getDirectoryPaths(testDir, "build/qwerty_*", true);
494
+ const notAbsolutes = getDirectoryPaths(testDir, "build/qwerty_*", false);
495
+
496
+
497
+ console.log(JSON.stringify({ absolutes, notAbsolutes }, null, 2));
498
+
499
+ expect(absolutes).toHaveLength(7);
500
+ expect(notAbsolutes).toHaveLength(7);
501
+
502
+
503
+ });
504
+
486
505
  });
487
506
 
488
507
 
508
+
509
+
489
510
  })
490
511
 
491
512
 
package/src/getPaths.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Glob } from "bun";
2
2
  import { statSync } from "fs";
3
+ import { join } from "path";
3
4
 
4
5
  /**
5
6
  * Gets file paths, directory paths, or both based on the specified parameters
@@ -94,7 +95,8 @@ export const getDirectoryPaths = (path: string, pattern: string = "**/*", absolu
94
95
 
95
96
  const directories = allItems.filter(item => {
96
97
  try {
97
- return statSync(item).isDirectory();
98
+ const fullPath = absolute ? item : join(path, item);
99
+ return statSync(fullPath).isDirectory();
98
100
  } catch {
99
101
  return false;
100
102
  }