@base-web-kits/base-tools-ts 1.4.2 → 1.4.9

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.
@@ -1,5 +1,6 @@
1
1
  export * from './file';
2
2
  export * from './oss';
3
3
  export * from './param';
4
+ export * from './path';
4
5
  export * from './qn';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ts/url/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ts/url/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,MAAM,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 拼接 URL 路径,并清理各部分交界处多余的斜杠。
3
+ *
4
+ * 空字符串、`null` 和 `undefined` 会被忽略;协议中的 `://` 以及第一个有效参数
5
+ * 开头的 `/` 会被保留。该函数仅用于拼接路径,不负责解析查询参数或哈希片段。
6
+ *
7
+ * @param parts URL 或路径片段
8
+ * @returns 拼接后的 URL 路径;没有有效片段时返回空字符串
9
+ * @example
10
+ * joinUrlPath('https://a.com/', '/images/', '/avatar.png');
11
+ * // 'https://a.com/images/avatar.png'
12
+ *
13
+ * joinUrlPath('', '/images/', null, 'avatar.png');
14
+ * // '/images/avatar.png'
15
+ */
16
+ export declare function joinUrlPath(...parts: Array<string | null | undefined>): string;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/url/path/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,UAarE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base-web-kits/base-tools-ts",
3
- "version": "1.4.2",
3
+ "version": "1.4.9",
4
4
  "sideEffects": false,
5
5
  "description": "Independent TS utilities package built from src/ts.",
6
6
  "keywords": [
@@ -1,199 +1,199 @@
1
- /**
2
- * re-export 全量 es-toolkit
3
- * 版本: 1.44.0
4
- * 文档: https://es-toolkit.dev/
5
- * 目的: 提供常用工具,收敛依赖版本
6
- * 导出策略: 必须使用显式命名导出, 不要使用 export *
7
- * 原因: 为了避免不同构建链路下出现最终入口导出表不完整的问题
8
- *
9
- * 注意: 此文件由 scripts/re-export/update-es-toolkit-exports.ts 生成, 请勿手动修改.
10
- * 如需更新, 请先升级es-toolkit, 然后运行: npm run update:es-toolkit
11
- */
12
- export {
13
- AbortError,
14
- Mutex,
15
- Semaphore,
16
- TimeoutError,
17
- after,
18
- ary,
19
- assert,
20
- asyncNoop,
21
- at,
22
- attempt,
23
- attemptAsync,
24
- before,
25
- camelCase,
26
- capitalize,
27
- chunk,
28
- clamp,
29
- clone,
30
- cloneDeep,
31
- cloneDeepWith,
32
- compact,
33
- constantCase,
34
- countBy,
35
- curry,
36
- curryRight,
37
- debounce,
38
- deburr,
39
- delay,
40
- difference,
41
- differenceBy,
42
- differenceWith,
43
- drop,
44
- dropRight,
45
- dropRightWhile,
46
- dropWhile,
47
- escape,
48
- escapeRegExp,
49
- fill,
50
- filterAsync,
51
- findKey,
52
- flatMap,
53
- flatMapAsync,
54
- flatMapDeep,
55
- flatten,
56
- flattenDeep,
57
- flattenObject,
58
- flow,
59
- flowRight,
60
- forEachAsync,
61
- forEachRight,
62
- groupBy,
63
- head,
64
- identity,
65
- inRange,
66
- initial,
67
- intersection,
68
- intersectionBy,
69
- intersectionWith,
70
- invariant,
71
- invert,
72
- isArrayBuffer,
73
- isBlob,
74
- isBoolean,
75
- isBrowser,
76
- isBuffer,
77
- isDate,
78
- isEmptyObject,
79
- isEqual,
80
- isEqualWith,
81
- isError,
82
- isFile,
83
- isFunction,
84
- isJSON,
85
- isJSONArray,
86
- isJSONObject,
87
- isJSONValue,
88
- isLength,
89
- isMap,
90
- isNil,
91
- isNode,
92
- isNotNil,
93
- isNull,
94
- isNumber,
95
- isPlainObject,
96
- isPrimitive,
97
- isPromise,
98
- isRegExp,
99
- isSet,
100
- isString,
101
- isSubset,
102
- isSubsetWith,
103
- isSymbol,
104
- isTypedArray,
105
- isUndefined,
106
- isWeakMap,
107
- isWeakSet,
108
- kebabCase,
109
- keyBy,
110
- last,
111
- limitAsync,
112
- lowerCase,
113
- lowerFirst,
114
- mapAsync,
115
- mapKeys,
116
- mapValues,
117
- maxBy,
118
- mean,
119
- meanBy,
120
- median,
121
- medianBy,
122
- memoize,
123
- merge,
124
- mergeWith,
125
- minBy,
126
- negate,
127
- noop,
128
- omit,
129
- omitBy,
130
- once,
131
- orderBy,
132
- pad,
133
- partial,
134
- partialRight,
135
- partition,
136
- pascalCase,
137
- pick,
138
- pickBy,
139
- pull,
140
- pullAt,
141
- random,
142
- randomInt,
143
- range,
144
- rangeRight,
145
- reduceAsync,
146
- remove,
147
- rest,
148
- retry,
149
- reverseString,
150
- round,
151
- sample,
152
- sampleSize,
153
- shuffle,
154
- snakeCase,
155
- sortBy,
156
- spread,
157
- startCase,
158
- sum,
159
- sumBy,
160
- tail,
161
- take,
162
- takeRight,
163
- takeRightWhile,
164
- takeWhile,
165
- throttle,
166
- timeout,
167
- toCamelCaseKeys,
168
- toFilled,
169
- toMerged,
170
- toSnakeCaseKeys,
171
- trim,
172
- trimEnd,
173
- trimStart,
174
- unary,
175
- unescape,
176
- union,
177
- unionBy,
178
- unionWith,
179
- uniq,
180
- uniqBy,
181
- uniqWith,
182
- unzip,
183
- unzipWith,
184
- upperCase,
185
- upperFirst,
186
- windowed,
187
- withTimeout,
188
- without,
189
- words,
190
- xor,
191
- xorBy,
192
- xorWith,
193
- zip,
194
- zipObject,
195
- zipWith,
196
- } from 'es-toolkit';
197
-
198
- // 导出类型
199
- export type * from 'es-toolkit';
1
+ /**
2
+ * re-export 全量 es-toolkit
3
+ * 版本: 1.44.0
4
+ * 文档: https://es-toolkit.dev/
5
+ * 目的: 提供常用工具,收敛依赖版本
6
+ * 导出策略: 必须使用显式命名导出, 不要使用 export *
7
+ * 原因: 为了避免不同构建链路下出现最终入口导出表不完整的问题
8
+ *
9
+ * 注意: 此文件由 scripts/re-export/update-es-toolkit-exports.ts 生成, 请勿手动修改.
10
+ * 如需更新, 请先升级es-toolkit, 然后运行: npm run update:es-toolkit
11
+ */
12
+ export {
13
+ AbortError,
14
+ Mutex,
15
+ Semaphore,
16
+ TimeoutError,
17
+ after,
18
+ ary,
19
+ assert,
20
+ asyncNoop,
21
+ at,
22
+ attempt,
23
+ attemptAsync,
24
+ before,
25
+ camelCase,
26
+ capitalize,
27
+ chunk,
28
+ clamp,
29
+ clone,
30
+ cloneDeep,
31
+ cloneDeepWith,
32
+ compact,
33
+ constantCase,
34
+ countBy,
35
+ curry,
36
+ curryRight,
37
+ debounce,
38
+ deburr,
39
+ delay,
40
+ difference,
41
+ differenceBy,
42
+ differenceWith,
43
+ drop,
44
+ dropRight,
45
+ dropRightWhile,
46
+ dropWhile,
47
+ escape,
48
+ escapeRegExp,
49
+ fill,
50
+ filterAsync,
51
+ findKey,
52
+ flatMap,
53
+ flatMapAsync,
54
+ flatMapDeep,
55
+ flatten,
56
+ flattenDeep,
57
+ flattenObject,
58
+ flow,
59
+ flowRight,
60
+ forEachAsync,
61
+ forEachRight,
62
+ groupBy,
63
+ head,
64
+ identity,
65
+ inRange,
66
+ initial,
67
+ intersection,
68
+ intersectionBy,
69
+ intersectionWith,
70
+ invariant,
71
+ invert,
72
+ isArrayBuffer,
73
+ isBlob,
74
+ isBoolean,
75
+ isBrowser,
76
+ isBuffer,
77
+ isDate,
78
+ isEmptyObject,
79
+ isEqual,
80
+ isEqualWith,
81
+ isError,
82
+ isFile,
83
+ isFunction,
84
+ isJSON,
85
+ isJSONArray,
86
+ isJSONObject,
87
+ isJSONValue,
88
+ isLength,
89
+ isMap,
90
+ isNil,
91
+ isNode,
92
+ isNotNil,
93
+ isNull,
94
+ isNumber,
95
+ isPlainObject,
96
+ isPrimitive,
97
+ isPromise,
98
+ isRegExp,
99
+ isSet,
100
+ isString,
101
+ isSubset,
102
+ isSubsetWith,
103
+ isSymbol,
104
+ isTypedArray,
105
+ isUndefined,
106
+ isWeakMap,
107
+ isWeakSet,
108
+ kebabCase,
109
+ keyBy,
110
+ last,
111
+ limitAsync,
112
+ lowerCase,
113
+ lowerFirst,
114
+ mapAsync,
115
+ mapKeys,
116
+ mapValues,
117
+ maxBy,
118
+ mean,
119
+ meanBy,
120
+ median,
121
+ medianBy,
122
+ memoize,
123
+ merge,
124
+ mergeWith,
125
+ minBy,
126
+ negate,
127
+ noop,
128
+ omit,
129
+ omitBy,
130
+ once,
131
+ orderBy,
132
+ pad,
133
+ partial,
134
+ partialRight,
135
+ partition,
136
+ pascalCase,
137
+ pick,
138
+ pickBy,
139
+ pull,
140
+ pullAt,
141
+ random,
142
+ randomInt,
143
+ range,
144
+ rangeRight,
145
+ reduceAsync,
146
+ remove,
147
+ rest,
148
+ retry,
149
+ reverseString,
150
+ round,
151
+ sample,
152
+ sampleSize,
153
+ shuffle,
154
+ snakeCase,
155
+ sortBy,
156
+ spread,
157
+ startCase,
158
+ sum,
159
+ sumBy,
160
+ tail,
161
+ take,
162
+ takeRight,
163
+ takeRightWhile,
164
+ takeWhile,
165
+ throttle,
166
+ timeout,
167
+ toCamelCaseKeys,
168
+ toFilled,
169
+ toMerged,
170
+ toSnakeCaseKeys,
171
+ trim,
172
+ trimEnd,
173
+ trimStart,
174
+ unary,
175
+ unescape,
176
+ union,
177
+ unionBy,
178
+ unionWith,
179
+ uniq,
180
+ uniqBy,
181
+ uniqWith,
182
+ unzip,
183
+ unzipWith,
184
+ upperCase,
185
+ upperFirst,
186
+ windowed,
187
+ withTimeout,
188
+ without,
189
+ words,
190
+ xor,
191
+ xorBy,
192
+ xorWith,
193
+ zip,
194
+ zipObject,
195
+ zipWith,
196
+ } from 'es-toolkit';
197
+
198
+ // 导出类型
199
+ export type * from 'es-toolkit';
@@ -1,4 +1,5 @@
1
1
  export * from './file';
2
- export * from './oss';
3
- export * from './param';
4
- export * from './qn';
2
+ export * from './oss';
3
+ export * from './param';
4
+ export * from './path';
5
+ export * from './qn';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 拼接 URL 路径,并清理各部分交界处多余的斜杠。
3
+ *
4
+ * 空字符串、`null` 和 `undefined` 会被忽略;协议中的 `://` 以及第一个有效参数
5
+ * 开头的 `/` 会被保留。该函数仅用于拼接路径,不负责解析查询参数或哈希片段。
6
+ *
7
+ * @param parts URL 或路径片段
8
+ * @returns 拼接后的 URL 路径;没有有效片段时返回空字符串
9
+ * @example
10
+ * joinUrlPath('https://a.com/', '/images/', '/avatar.png');
11
+ * // 'https://a.com/images/avatar.png'
12
+ *
13
+ * joinUrlPath('', '/images/', null, 'avatar.png');
14
+ * // '/images/avatar.png'
15
+ */
16
+ export function joinUrlPath(...parts: Array<string | null | undefined>) {
17
+ const values = parts.filter((part): part is string => !!part);
18
+ if (!values.length) return '';
19
+
20
+ const [first, ...rest] = values;
21
+ const normalizedFirst = first.replace(/\/+$/, '');
22
+ const normalizedRest = rest.map((part) => part.replace(/^\/+|\/+$/g, '')).filter(Boolean);
23
+
24
+ if (!normalizedRest.length) {
25
+ return normalizedFirst || (first.startsWith('/') ? '/' : '');
26
+ }
27
+
28
+ return `${normalizedFirst}/${normalizedRest.join('/')}`;
29
+ }