xshell 1.2.53 → 1.2.54

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": "xshell",
3
- "version": "1.2.53",
3
+ "version": "1.2.54",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -20,6 +20,8 @@ export declare function zip_object<TValue>(keys: (string | number)[], values: TV
20
20
  - obj: 对象
21
21
  - mapper?: `to_snake_case` (key: string) => string 或者 Record<string, string> */
22
22
  export declare function map_keys<TReturn>(obj: any, mapper?: ((key: string) => string) | Record<string, string>): TReturn;
23
+ /** 返回一个映射对象 keys 的函数,通常和 .map 函数一起使用 */
24
+ export declare function get_key_mapper<TReturn>(mapper?: ((key: string) => string) | Record<string, string>): (obj: any) => TReturn;
23
25
  /** 过滤对象中的 values, 返回新对象
24
26
  - obj
25
27
  - filter?: `not_empty` */
package/utils.browser.js CHANGED
@@ -64,6 +64,10 @@ export function map_keys(obj, mapper = to_snake_case) {
64
64
  :
65
65
  ([key, value]) => [mapper[key] || key, value]));
66
66
  }
67
+ /** 返回一个映射对象 keys 的函数,通常和 .map 函数一起使用 */
68
+ export function get_key_mapper(mapper = to_snake_case) {
69
+ return (obj) => map_keys(obj, mapper);
70
+ }
67
71
  /** 过滤对象中的 values, 返回新对象
68
72
  - obj
69
73
  - filter?: `not_empty` */
package/utils.d.ts CHANGED
@@ -29,6 +29,8 @@ export declare function zip_object<TValue>(keys: (string | number)[], values: TV
29
29
  - obj: 对象
30
30
  - mapper?: `to_snake_case` (key: string) => string 或者 Record<string, string> */
31
31
  export declare function map_keys<TReturn>(obj: any, mapper?: ((key: string) => string) | Record<string, string>): TReturn;
32
+ /** 返回一个映射对象 keys 的函数,通常和 .map 函数一起使用 */
33
+ export declare function get_key_mapper<TReturn>(mapper?: ((key: string) => string) | Record<string, string>): (obj: any) => TReturn;
32
34
  /** 映射对象中的 values, 返回新对象 */
33
35
  export declare function map_values<TValue, TNewValue>(obj: {
34
36
  [key: string]: TValue;
package/utils.js CHANGED
@@ -91,6 +91,10 @@ export function map_keys(obj, mapper = to_snake_case) {
91
91
  :
92
92
  ([key, value]) => [mapper[key] || key, value]));
93
93
  }
94
+ /** 返回一个映射对象 keys 的函数,通常和 .map 函数一起使用 */
95
+ export function get_key_mapper(mapper = to_snake_case) {
96
+ return (obj) => map_keys(obj, mapper);
97
+ }
94
98
  /** 映射对象中的 values, 返回新对象 */
95
99
  export function map_values(obj, mapper) {
96
100
  return Object.fromEntries(Object.entries(obj)