typetify 2.4.0 → 4.0.1

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.
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Parsed path components.
3
+ */
4
+ interface ParsedPath {
5
+ root: string;
6
+ dir: string;
7
+ base: string;
8
+ ext: string;
9
+ name: string;
10
+ }
11
+ /**
12
+ * Parses a path into its components.
13
+ *
14
+ * @example
15
+ * parsePath('/home/user/file.txt');
16
+ * // => { root: '/', dir: '/home/user', base: 'file.txt', ext: '.txt', name: 'file' }
17
+ *
18
+ * @example
19
+ * parsePath('C:\\Users\\file.txt');
20
+ * // => { root: 'C:\\', dir: 'C:\\Users', base: 'file.txt', ext: '.txt', name: 'file' }
21
+ */
22
+ declare function parsePath(path: string): ParsedPath;
23
+ /**
24
+ * Gets the directory name of a path.
25
+ *
26
+ * @example
27
+ * dirname('/home/user/file.txt');
28
+ * // => '/home/user'
29
+ *
30
+ * @example
31
+ * dirname('file.txt');
32
+ * // => '.'
33
+ */
34
+ declare function dirname(path: string): string;
35
+ /**
36
+ * Gets the base name of a path.
37
+ *
38
+ * @example
39
+ * basename('/home/user/file.txt');
40
+ * // => 'file.txt'
41
+ *
42
+ * @example
43
+ * basename('/home/user/file.txt', '.txt');
44
+ * // => 'file'
45
+ */
46
+ declare function basename(path: string, ext?: string): string;
47
+ /**
48
+ * Gets the extension of a path.
49
+ *
50
+ * @example
51
+ * extname('/home/user/file.txt');
52
+ * // => '.txt'
53
+ *
54
+ * @example
55
+ * extname('file');
56
+ * // => ''
57
+ */
58
+ declare function extname(path: string): string;
59
+
60
+ /**
61
+ * Joins path segments together.
62
+ *
63
+ * @example
64
+ * joinPath('/home', 'user', 'file.txt');
65
+ * // => '/home/user/file.txt'
66
+ *
67
+ * @example
68
+ * joinPath('api', 'v1', 'users');
69
+ * // => 'api/v1/users'
70
+ *
71
+ * @example
72
+ * joinPath('/home/', '/user/', '/file.txt');
73
+ * // => '/home/user/file.txt'
74
+ */
75
+ declare function joinPath(...segments: string[]): string;
76
+ /**
77
+ * Resolves a sequence of paths to an absolute path.
78
+ *
79
+ * @example
80
+ * resolvePath('/home/user', '../admin', 'file.txt');
81
+ * // => '/home/admin/file.txt'
82
+ *
83
+ * @example
84
+ * resolvePath('src', '..', 'dist', 'index.js');
85
+ * // => '/current/working/dir/dist/index.js' (relative to cwd)
86
+ */
87
+ declare function resolvePath(...segments: string[]): string;
88
+ /**
89
+ * Gets the relative path from one path to another.
90
+ *
91
+ * @example
92
+ * relativePath('/home/user/docs', '/home/user/images');
93
+ * // => '../images'
94
+ *
95
+ * @example
96
+ * relativePath('/home/user', '/home/user/docs/file.txt');
97
+ * // => 'docs/file.txt'
98
+ */
99
+ declare function relativePath(from: string, to: string): string;
100
+
101
+ /**
102
+ * Normalizes a path, resolving '..' and '.' segments.
103
+ *
104
+ * @example
105
+ * normalizePath('/home/user/../admin/./file.txt');
106
+ * // => '/home/admin/file.txt'
107
+ *
108
+ * @example
109
+ * normalizePath('src/../dist/./index.js');
110
+ * // => 'dist/index.js'
111
+ */
112
+ declare function normalizePath(path: string): string;
113
+ /**
114
+ * Checks if a path is absolute.
115
+ *
116
+ * @example
117
+ * isAbsolute('/home/user');
118
+ * // => true
119
+ *
120
+ * @example
121
+ * isAbsolute('C:\\Users');
122
+ * // => true
123
+ *
124
+ * @example
125
+ * isAbsolute('src/file.txt');
126
+ * // => false
127
+ */
128
+ declare function isAbsolute(path: string): boolean;
129
+ /**
130
+ * Converts a path to POSIX format (forward slashes).
131
+ *
132
+ * @example
133
+ * toPosix('C:\\Users\\file.txt');
134
+ * // => 'C:/Users/file.txt'
135
+ */
136
+ declare function toPosix(path: string): string;
137
+ /**
138
+ * Converts a path to Windows format (backslashes).
139
+ *
140
+ * @example
141
+ * toWindows('/home/user/file.txt');
142
+ * // => '\\home\\user\\file.txt'
143
+ */
144
+ declare function toWindows(path: string): string;
145
+ /**
146
+ * Removes trailing slashes from a path.
147
+ *
148
+ * @example
149
+ * removeTrailingSlash('/home/user/');
150
+ * // => '/home/user'
151
+ *
152
+ * @example
153
+ * removeTrailingSlash('/');
154
+ * // => '/'
155
+ */
156
+ declare function removeTrailingSlash(path: string): string;
157
+ /**
158
+ * Ensures a path has a trailing slash.
159
+ *
160
+ * @example
161
+ * ensureTrailingSlash('/home/user');
162
+ * // => '/home/user/'
163
+ */
164
+ declare function ensureTrailingSlash(path: string): string;
165
+ /**
166
+ * Gets the common base path of multiple paths.
167
+ *
168
+ * @example
169
+ * commonPath(['/home/user/docs', '/home/user/images', '/home/user/videos']);
170
+ * // => '/home/user'
171
+ *
172
+ * @example
173
+ * commonPath(['src/utils/a.ts', 'src/utils/b.ts', 'src/helpers/c.ts']);
174
+ * // => 'src'
175
+ */
176
+ declare function commonPath(paths: string[]): string;
177
+
178
+ export { type ParsedPath, basename, commonPath, dirname, ensureTrailingSlash, extname, isAbsolute, joinPath, normalizePath, parsePath, relativePath, removeTrailingSlash, resolvePath, toPosix, toWindows };
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Parsed path components.
3
+ */
4
+ interface ParsedPath {
5
+ root: string;
6
+ dir: string;
7
+ base: string;
8
+ ext: string;
9
+ name: string;
10
+ }
11
+ /**
12
+ * Parses a path into its components.
13
+ *
14
+ * @example
15
+ * parsePath('/home/user/file.txt');
16
+ * // => { root: '/', dir: '/home/user', base: 'file.txt', ext: '.txt', name: 'file' }
17
+ *
18
+ * @example
19
+ * parsePath('C:\\Users\\file.txt');
20
+ * // => { root: 'C:\\', dir: 'C:\\Users', base: 'file.txt', ext: '.txt', name: 'file' }
21
+ */
22
+ declare function parsePath(path: string): ParsedPath;
23
+ /**
24
+ * Gets the directory name of a path.
25
+ *
26
+ * @example
27
+ * dirname('/home/user/file.txt');
28
+ * // => '/home/user'
29
+ *
30
+ * @example
31
+ * dirname('file.txt');
32
+ * // => '.'
33
+ */
34
+ declare function dirname(path: string): string;
35
+ /**
36
+ * Gets the base name of a path.
37
+ *
38
+ * @example
39
+ * basename('/home/user/file.txt');
40
+ * // => 'file.txt'
41
+ *
42
+ * @example
43
+ * basename('/home/user/file.txt', '.txt');
44
+ * // => 'file'
45
+ */
46
+ declare function basename(path: string, ext?: string): string;
47
+ /**
48
+ * Gets the extension of a path.
49
+ *
50
+ * @example
51
+ * extname('/home/user/file.txt');
52
+ * // => '.txt'
53
+ *
54
+ * @example
55
+ * extname('file');
56
+ * // => ''
57
+ */
58
+ declare function extname(path: string): string;
59
+
60
+ /**
61
+ * Joins path segments together.
62
+ *
63
+ * @example
64
+ * joinPath('/home', 'user', 'file.txt');
65
+ * // => '/home/user/file.txt'
66
+ *
67
+ * @example
68
+ * joinPath('api', 'v1', 'users');
69
+ * // => 'api/v1/users'
70
+ *
71
+ * @example
72
+ * joinPath('/home/', '/user/', '/file.txt');
73
+ * // => '/home/user/file.txt'
74
+ */
75
+ declare function joinPath(...segments: string[]): string;
76
+ /**
77
+ * Resolves a sequence of paths to an absolute path.
78
+ *
79
+ * @example
80
+ * resolvePath('/home/user', '../admin', 'file.txt');
81
+ * // => '/home/admin/file.txt'
82
+ *
83
+ * @example
84
+ * resolvePath('src', '..', 'dist', 'index.js');
85
+ * // => '/current/working/dir/dist/index.js' (relative to cwd)
86
+ */
87
+ declare function resolvePath(...segments: string[]): string;
88
+ /**
89
+ * Gets the relative path from one path to another.
90
+ *
91
+ * @example
92
+ * relativePath('/home/user/docs', '/home/user/images');
93
+ * // => '../images'
94
+ *
95
+ * @example
96
+ * relativePath('/home/user', '/home/user/docs/file.txt');
97
+ * // => 'docs/file.txt'
98
+ */
99
+ declare function relativePath(from: string, to: string): string;
100
+
101
+ /**
102
+ * Normalizes a path, resolving '..' and '.' segments.
103
+ *
104
+ * @example
105
+ * normalizePath('/home/user/../admin/./file.txt');
106
+ * // => '/home/admin/file.txt'
107
+ *
108
+ * @example
109
+ * normalizePath('src/../dist/./index.js');
110
+ * // => 'dist/index.js'
111
+ */
112
+ declare function normalizePath(path: string): string;
113
+ /**
114
+ * Checks if a path is absolute.
115
+ *
116
+ * @example
117
+ * isAbsolute('/home/user');
118
+ * // => true
119
+ *
120
+ * @example
121
+ * isAbsolute('C:\\Users');
122
+ * // => true
123
+ *
124
+ * @example
125
+ * isAbsolute('src/file.txt');
126
+ * // => false
127
+ */
128
+ declare function isAbsolute(path: string): boolean;
129
+ /**
130
+ * Converts a path to POSIX format (forward slashes).
131
+ *
132
+ * @example
133
+ * toPosix('C:\\Users\\file.txt');
134
+ * // => 'C:/Users/file.txt'
135
+ */
136
+ declare function toPosix(path: string): string;
137
+ /**
138
+ * Converts a path to Windows format (backslashes).
139
+ *
140
+ * @example
141
+ * toWindows('/home/user/file.txt');
142
+ * // => '\\home\\user\\file.txt'
143
+ */
144
+ declare function toWindows(path: string): string;
145
+ /**
146
+ * Removes trailing slashes from a path.
147
+ *
148
+ * @example
149
+ * removeTrailingSlash('/home/user/');
150
+ * // => '/home/user'
151
+ *
152
+ * @example
153
+ * removeTrailingSlash('/');
154
+ * // => '/'
155
+ */
156
+ declare function removeTrailingSlash(path: string): string;
157
+ /**
158
+ * Ensures a path has a trailing slash.
159
+ *
160
+ * @example
161
+ * ensureTrailingSlash('/home/user');
162
+ * // => '/home/user/'
163
+ */
164
+ declare function ensureTrailingSlash(path: string): string;
165
+ /**
166
+ * Gets the common base path of multiple paths.
167
+ *
168
+ * @example
169
+ * commonPath(['/home/user/docs', '/home/user/images', '/home/user/videos']);
170
+ * // => '/home/user'
171
+ *
172
+ * @example
173
+ * commonPath(['src/utils/a.ts', 'src/utils/b.ts', 'src/helpers/c.ts']);
174
+ * // => 'src'
175
+ */
176
+ declare function commonPath(paths: string[]): string;
177
+
178
+ export { type ParsedPath, basename, commonPath, dirname, ensureTrailingSlash, extname, isAbsolute, joinPath, normalizePath, parsePath, relativePath, removeTrailingSlash, resolvePath, toPosix, toWindows };
@@ -0,0 +1 @@
1
+ 'use strict';var chunkC5X2N4X4_js=require('../chunk-C5X2N4X4.js');require('../chunk-WOT6VMZA.js');Object.defineProperty(exports,"basename",{enumerable:true,get:function(){return chunkC5X2N4X4_js.c}});Object.defineProperty(exports,"commonPath",{enumerable:true,get:function(){return chunkC5X2N4X4_js.n}});Object.defineProperty(exports,"dirname",{enumerable:true,get:function(){return chunkC5X2N4X4_js.b}});Object.defineProperty(exports,"ensureTrailingSlash",{enumerable:true,get:function(){return chunkC5X2N4X4_js.m}});Object.defineProperty(exports,"extname",{enumerable:true,get:function(){return chunkC5X2N4X4_js.d}});Object.defineProperty(exports,"isAbsolute",{enumerable:true,get:function(){return chunkC5X2N4X4_js.i}});Object.defineProperty(exports,"joinPath",{enumerable:true,get:function(){return chunkC5X2N4X4_js.e}});Object.defineProperty(exports,"normalizePath",{enumerable:true,get:function(){return chunkC5X2N4X4_js.h}});Object.defineProperty(exports,"parsePath",{enumerable:true,get:function(){return chunkC5X2N4X4_js.a}});Object.defineProperty(exports,"relativePath",{enumerable:true,get:function(){return chunkC5X2N4X4_js.g}});Object.defineProperty(exports,"removeTrailingSlash",{enumerable:true,get:function(){return chunkC5X2N4X4_js.l}});Object.defineProperty(exports,"resolvePath",{enumerable:true,get:function(){return chunkC5X2N4X4_js.f}});Object.defineProperty(exports,"toPosix",{enumerable:true,get:function(){return chunkC5X2N4X4_js.j}});Object.defineProperty(exports,"toWindows",{enumerable:true,get:function(){return chunkC5X2N4X4_js.k}});
@@ -0,0 +1 @@
1
+ export{c as basename,n as commonPath,b as dirname,m as ensureTrailingSlash,d as extname,i as isAbsolute,e as joinPath,h as normalizePath,a as parsePath,g as relativePath,l as removeTrailingSlash,f as resolvePath,j as toPosix,k as toWindows}from'../chunk-H7MLD632.mjs';import'../chunk-JZXLCA2E.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typetify",
3
- "version": "2.4.0",
3
+ "version": "4.0.1",
4
4
  "description": "Runtime TypeScript helpers - like Lodash, but TS-first",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -115,6 +115,26 @@
115
115
  "types": "./dist/color/index.d.ts",
116
116
  "import": "./dist/color/index.mjs",
117
117
  "require": "./dist/color/index.js"
118
+ },
119
+ "./http": {
120
+ "types": "./dist/http/index.d.ts",
121
+ "import": "./dist/http/index.mjs",
122
+ "require": "./dist/http/index.js"
123
+ },
124
+ "./datetime": {
125
+ "types": "./dist/datetime/index.d.ts",
126
+ "import": "./dist/datetime/index.mjs",
127
+ "require": "./dist/datetime/index.js"
128
+ },
129
+ "./path": {
130
+ "types": "./dist/path/index.d.ts",
131
+ "import": "./dist/path/index.mjs",
132
+ "require": "./dist/path/index.js"
133
+ },
134
+ "./encrypt": {
135
+ "types": "./dist/encrypt/index.d.ts",
136
+ "import": "./dist/encrypt/index.mjs",
137
+ "require": "./dist/encrypt/index.js"
118
138
  }
119
139
  },
120
140
  "files": [