@pawover/kit 0.0.0-alpha.6 → 0.0.0-alpha.7
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.
|
@@ -51,3 +51,4 @@ export declare function enumValues<E extends AnyObject>(enumeration: NonEmptyObj
|
|
|
51
51
|
* @param enumeration 枚举
|
|
52
52
|
*/
|
|
53
53
|
export declare function enumEntries<E extends AnyObject>(enumeration: NonEmptyObject<E>): [keyof E, E[keyof E]][];
|
|
54
|
+
export declare function mapEntries<TKey extends PropertyKey, TValue, TNewKey extends PropertyKey, TNewValue>(obj: UnknownObject<TKey, TValue>, toEntry: (key: TKey, value: TValue) => [TNewKey, TNewValue]): UnknownObject<TNewKey, TNewValue>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Replace } from "type-fest";
|
|
1
2
|
/**
|
|
2
3
|
* 转义特殊字符
|
|
3
4
|
*
|
|
@@ -11,3 +12,4 @@ export declare function escapeStringRegexp(value: string): string;
|
|
|
11
12
|
export declare function stringInitialCase(value: string, type: "lower" | "upper"): string;
|
|
12
13
|
export declare function stringToJson<R extends AnyObject = AnyObject, D extends R = R>(data: string | null | undefined, safeValue: D): R;
|
|
13
14
|
export declare function stringToValues<T extends number | string = number>(data: string | null | undefined, valueType?: "number" | "string"): T[];
|
|
15
|
+
export declare function stringReplace<I extends string, S extends string, R extends string>(input: I, search: S, replacement: R): Replace<I, S, R>;
|
package/dist/utils/object.js
CHANGED
|
@@ -54,9 +54,9 @@ export function objectAssign(obj, overrideObj) {
|
|
|
54
54
|
if (!isObject(obj) || !isObject(overrideObj)) {
|
|
55
55
|
return obj ?? overrideObj ?? result;
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return objectEntries({ ...obj, ...overrideObj }).reduce((acc, [key, value]) => {
|
|
58
58
|
return {
|
|
59
|
-
...
|
|
59
|
+
...acc,
|
|
60
60
|
[key]: (() => {
|
|
61
61
|
if (isObject(obj[key])) {
|
|
62
62
|
return objectAssign(obj[key], value);
|
|
@@ -74,11 +74,11 @@ export function objectPick(obj, keys) {
|
|
|
74
74
|
if (!isArray(keys)) {
|
|
75
75
|
return obj;
|
|
76
76
|
}
|
|
77
|
-
return keys.reduce((
|
|
77
|
+
return keys.reduce((acc, curr) => {
|
|
78
78
|
if (curr in obj) {
|
|
79
|
-
|
|
79
|
+
acc[curr] = obj[curr];
|
|
80
80
|
}
|
|
81
|
-
return
|
|
81
|
+
return acc;
|
|
82
82
|
}, result);
|
|
83
83
|
}
|
|
84
84
|
function enumType(enumeration) {
|
|
@@ -136,3 +136,14 @@ export function enumEntries(enumeration) {
|
|
|
136
136
|
}
|
|
137
137
|
return entries;
|
|
138
138
|
}
|
|
139
|
+
export function mapEntries(obj, toEntry) {
|
|
140
|
+
const defaultResult = {};
|
|
141
|
+
if (!obj) {
|
|
142
|
+
return defaultResult;
|
|
143
|
+
}
|
|
144
|
+
return objectEntries(obj).reduce((acc, [key, value]) => {
|
|
145
|
+
const [newKey, newValue] = toEntry(key, value);
|
|
146
|
+
acc[newKey] = newValue;
|
|
147
|
+
return acc;
|
|
148
|
+
}, defaultResult);
|
|
149
|
+
}
|
package/dist/utils/string.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "pawover's kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.0.0-alpha.
|
|
7
|
+
"version": "0.0.0-alpha.7",
|
|
8
8
|
"packageManager": "pnpm@10.20.0",
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": ">=22.20.0"
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"lib:up": "taze -I -r --exclude pnpm"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@pawover/eslint-rules": "0.0.0-alpha.
|
|
54
|
+
"@pawover/eslint-rules": "0.0.0-alpha.7",
|
|
55
55
|
"@pawover/types": "0.0.0-alpha.6",
|
|
56
56
|
"@stylistic/eslint-plugin": "^5.5.0",
|
|
57
57
|
"@types/node": "^24.10.1",
|
|
58
|
-
"@types/react": "^19.2.
|
|
58
|
+
"@types/react": "^19.2.5",
|
|
59
59
|
"ahooks": "^3.9.6",
|
|
60
60
|
"eslint": "^9.39.1",
|
|
61
61
|
"eslint-plugin-antfu": "^3.1.1",
|