xcn 1.1.0 → 1.1.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 +0 -4
- package/cjs/index.js +30 -2
- package/es/index.js +30 -2
- package/es/{src → types/src}/index.d.ts +30 -2
- package/package.json +12 -13
package/README.md
CHANGED
package/cjs/index.js
CHANGED
|
@@ -5,11 +5,39 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var aTypeOfJs = require('a-type-of-js');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
+
* 以空格为分隔符拼接字符串
|
|
9
|
+
* @param classNameList 待拼接的字符串
|
|
10
|
+
* @return string 拼接后的字符串
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { xcn } from 'xcn';
|
|
8
14
|
*
|
|
9
|
-
*
|
|
15
|
+
* // 以纯字符串为参数
|
|
16
|
+
* // 'a b c'
|
|
17
|
+
* xcn('a', 'b', 'c');
|
|
10
18
|
*
|
|
11
|
-
*
|
|
19
|
+
* // 剔除多余的空格
|
|
20
|
+
* // 'a b c'
|
|
21
|
+
* xcn('a ', ' b ', 'c ');
|
|
12
22
|
*
|
|
23
|
+
* // 参数可以是字符串数组
|
|
24
|
+
* // 'a b c d e'
|
|
25
|
+
* xcn(['a', 'b'], ['c', 'd'], 'e');
|
|
26
|
+
*
|
|
27
|
+
* // 参数可为可执行返回值为字符串的或字符串数组的函数
|
|
28
|
+
* // 'a b c d e f g'
|
|
29
|
+
* xcn('a', ' b ', ['c', 'd'] , ()=> 'e', () => ['f', 'g']);
|
|
30
|
+
*
|
|
31
|
+
* // 参数可为简单对象,以键入参,以值为断
|
|
32
|
+
* // 'a b c e g'
|
|
33
|
+
* xcn('a', 'b', {
|
|
34
|
+
* c: true,
|
|
35
|
+
* d: false,
|
|
36
|
+
* e: !0,
|
|
37
|
+
* f: !1,
|
|
38
|
+
* g: 1 > 0
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
13
41
|
*/
|
|
14
42
|
function xcn(...classNameList) {
|
|
15
43
|
/** 临时 */
|
package/es/index.js
CHANGED
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
import { isTrue, isArray, isString, isNumber, isFunction, isUndefined } from 'a-type-of-js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
+
* 以空格为分隔符拼接字符串
|
|
5
|
+
* @param classNameList 待拼接的字符串
|
|
6
|
+
* @return string 拼接后的字符串
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { xcn } from 'xcn';
|
|
4
10
|
*
|
|
5
|
-
*
|
|
11
|
+
* // 以纯字符串为参数
|
|
12
|
+
* // 'a b c'
|
|
13
|
+
* xcn('a', 'b', 'c');
|
|
6
14
|
*
|
|
7
|
-
*
|
|
15
|
+
* // 剔除多余的空格
|
|
16
|
+
* // 'a b c'
|
|
17
|
+
* xcn('a ', ' b ', 'c ');
|
|
8
18
|
*
|
|
19
|
+
* // 参数可以是字符串数组
|
|
20
|
+
* // 'a b c d e'
|
|
21
|
+
* xcn(['a', 'b'], ['c', 'd'], 'e');
|
|
22
|
+
*
|
|
23
|
+
* // 参数可为可执行返回值为字符串的或字符串数组的函数
|
|
24
|
+
* // 'a b c d e f g'
|
|
25
|
+
* xcn('a', ' b ', ['c', 'd'] , ()=> 'e', () => ['f', 'g']);
|
|
26
|
+
*
|
|
27
|
+
* // 参数可为简单对象,以键入参,以值为断
|
|
28
|
+
* // 'a b c e g'
|
|
29
|
+
* xcn('a', 'b', {
|
|
30
|
+
* c: true,
|
|
31
|
+
* d: false,
|
|
32
|
+
* e: !0,
|
|
33
|
+
* f: !1,
|
|
34
|
+
* g: 1 > 0
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
9
37
|
*/
|
|
10
38
|
function xcn(...classNameList) {
|
|
11
39
|
/** 临时 */
|
|
@@ -13,11 +13,39 @@ export type EnTypeofClassNameItem<T> = T extends null | boolean | undefined ? ''
|
|
|
13
13
|
*/
|
|
14
14
|
export type EnXcn<T> = T extends [infer U, ...infer V] ? `${U & string} ${EnXcn<V>}` : '';
|
|
15
15
|
/**
|
|
16
|
+
* 以空格为分隔符拼接字符串
|
|
17
|
+
* @param classNameList 待拼接的字符串
|
|
18
|
+
* @return string 拼接后的字符串
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { xcn } from 'xcn';
|
|
16
22
|
*
|
|
17
|
-
*
|
|
23
|
+
* // 以纯字符串为参数
|
|
24
|
+
* // 'a b c'
|
|
25
|
+
* xcn('a', 'b', 'c');
|
|
18
26
|
*
|
|
19
|
-
*
|
|
27
|
+
* // 剔除多余的空格
|
|
28
|
+
* // 'a b c'
|
|
29
|
+
* xcn('a ', ' b ', 'c ');
|
|
20
30
|
*
|
|
31
|
+
* // 参数可以是字符串数组
|
|
32
|
+
* // 'a b c d e'
|
|
33
|
+
* xcn(['a', 'b'], ['c', 'd'], 'e');
|
|
34
|
+
*
|
|
35
|
+
* // 参数可为可执行返回值为字符串的或字符串数组的函数
|
|
36
|
+
* // 'a b c d e f g'
|
|
37
|
+
* xcn('a', ' b ', ['c', 'd'] , ()=> 'e', () => ['f', 'g']);
|
|
38
|
+
*
|
|
39
|
+
* // 参数可为简单对象,以键入参,以值为断
|
|
40
|
+
* // 'a b c e g'
|
|
41
|
+
* xcn('a', 'b', {
|
|
42
|
+
* c: true,
|
|
43
|
+
* d: false,
|
|
44
|
+
* e: !0,
|
|
45
|
+
* f: !1,
|
|
46
|
+
* g: 1 > 0
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
21
49
|
*/
|
|
22
50
|
export declare function xcn<T extends EnClassNameItem[]>(...classNameList: T): EnXcn<{
|
|
23
51
|
[K in keyof T]: EnTypeofClassNameItem<T[K]>;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xcn",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
|
-
"types": "es/src/index.d.ts",
|
|
7
|
+
"types": "es/types/src/index.d.ts",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "泥豆君",
|
|
10
10
|
"email": "Mr.MudBean@outlook.com",
|
|
11
|
-
"url": "https://
|
|
11
|
+
"url": "https://lmssee.com"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public",
|
|
@@ -24,19 +24,21 @@
|
|
|
24
24
|
"README.md"
|
|
25
25
|
],
|
|
26
26
|
"exports": {
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./es/index.js",
|
|
29
|
+
"default": "./es/index.js",
|
|
30
|
+
"require": "./cjs/index.js",
|
|
31
|
+
"types": "./es/types/src/index.d.ts"
|
|
32
|
+
}
|
|
31
33
|
},
|
|
32
34
|
"keywords": [
|
|
33
35
|
"xcn",
|
|
34
36
|
"混合 className",
|
|
35
37
|
"拼接字符串"
|
|
36
38
|
],
|
|
37
|
-
"homepage": "https://
|
|
39
|
+
"homepage": "https://lmssee.com/npm/xcn",
|
|
38
40
|
"dependencies": {
|
|
39
|
-
"a-type-of-js": "^2.0.
|
|
41
|
+
"a-type-of-js": "^2.0.1"
|
|
40
42
|
},
|
|
41
43
|
"bugs": {
|
|
42
44
|
"url": "https://github.com/MrMudBean/xcn/issues",
|
|
@@ -48,8 +50,5 @@
|
|
|
48
50
|
},
|
|
49
51
|
"browserslist": [
|
|
50
52
|
"last 2 versions not ie <= 11"
|
|
51
|
-
]
|
|
52
|
-
"engines": {
|
|
53
|
-
"node": ">=18.0.0"
|
|
54
|
-
}
|
|
53
|
+
]
|
|
55
54
|
}
|