@zwa73/utils 1.0.39 → 1.0.41
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/dist/UtilCom.js +1 -1
- package/dist/UtilInterfaces.d.ts +8 -6
- package/dist/UtilInterfaces.js +1 -1
- package/package.json +1 -1
- package/src/UtilCom.ts +1 -1
- package/src/UtilInterfaces.ts +9 -6
package/dist/UtilCom.js
CHANGED
package/dist/UtilInterfaces.d.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
+
/**可以序列化为JSON文件的对象 */
|
|
1
2
|
export type JToken = JObject | JArray | JValue | IJData;
|
|
2
|
-
|
|
3
|
+
/**在stringify输出时 undefine 会被转为 null */
|
|
4
|
+
export type JValue = number | string | boolean | null | undefined;
|
|
5
|
+
/**在stringify输出时 值为 undefine 的成员会被转为 null */
|
|
3
6
|
export type JArray = Array<JToken>;
|
|
4
|
-
|
|
7
|
+
/**在stringify输出时 值为 undefine 的键会被忽略 */
|
|
5
8
|
export type JObject = {
|
|
6
9
|
[key: string]: JToken;
|
|
7
10
|
};
|
|
8
|
-
/**可以保存为JToken的类
|
|
9
|
-
*/
|
|
11
|
+
/**可以保存为JToken的类 */
|
|
10
12
|
export interface IJData {
|
|
11
13
|
/**保存为JToken
|
|
12
14
|
*/
|
|
13
15
|
toJSON(): JToken;
|
|
14
16
|
}
|
|
15
17
|
/**将JToken转换为字符串
|
|
16
|
-
* @param {JToken} token - 待转换的Token
|
|
18
|
+
* @param {JToken|IJData} token - 待转换的Token
|
|
17
19
|
* @param {string|number|null} space - 插入的空格 数字为空格数量 默认为制表符\t
|
|
18
20
|
* @returns 转换完成的字符串
|
|
19
21
|
*/
|
|
20
|
-
export declare function stringifyJToken(token: JToken, space?: string | number | null | undefined): string;
|
|
22
|
+
export declare function stringifyJToken(token: JToken | IJData, space?: string | number | null | undefined): string;
|
|
21
23
|
/**转为可写的 */
|
|
22
24
|
export type Writeable<T> = {
|
|
23
25
|
-readonly [P in keyof T]: T[P];
|
package/dist/UtilInterfaces.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stringifyJToken = void 0;
|
|
4
4
|
/**将JToken转换为字符串
|
|
5
|
-
* @param {JToken} token - 待转换的Token
|
|
5
|
+
* @param {JToken|IJData} token - 待转换的Token
|
|
6
6
|
* @param {string|number|null} space - 插入的空格 数字为空格数量 默认为制表符\t
|
|
7
7
|
* @returns 转换完成的字符串
|
|
8
8
|
*/
|
package/package.json
CHANGED
package/src/UtilCom.ts
CHANGED
package/src/UtilInterfaces.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
3
|
+
/**可以序列化为JSON文件的对象 */
|
|
2
4
|
export type JToken = JObject|JArray|JValue|IJData;
|
|
3
|
-
|
|
5
|
+
/**在stringify输出时 undefine 会被转为 null */
|
|
6
|
+
export type JValue = number|string|boolean|null|undefined;
|
|
7
|
+
/**在stringify输出时 值为 undefine 的成员会被转为 null */
|
|
4
8
|
export type JArray = Array<JToken>;
|
|
5
|
-
|
|
9
|
+
/**在stringify输出时 值为 undefine 的键会被忽略 */
|
|
6
10
|
export type JObject = {
|
|
7
11
|
[key:string]:JToken;
|
|
8
12
|
}
|
|
9
|
-
/**可以保存为JToken的类
|
|
10
|
-
*/
|
|
13
|
+
/**可以保存为JToken的类 */
|
|
11
14
|
export interface IJData{
|
|
12
15
|
/**保存为JToken
|
|
13
16
|
*/
|
|
14
17
|
toJSON():JToken;
|
|
15
18
|
}
|
|
16
19
|
/**将JToken转换为字符串
|
|
17
|
-
* @param {JToken} token - 待转换的Token
|
|
20
|
+
* @param {JToken|IJData} token - 待转换的Token
|
|
18
21
|
* @param {string|number|null} space - 插入的空格 数字为空格数量 默认为制表符\t
|
|
19
22
|
* @returns 转换完成的字符串
|
|
20
23
|
*/
|
|
21
|
-
export function stringifyJToken(token:JToken,space:string|number|null|undefined="\t"){
|
|
24
|
+
export function stringifyJToken(token:JToken|IJData,space:string|number|null|undefined="\t"){
|
|
22
25
|
if(space==null)
|
|
23
26
|
space=undefined;
|
|
24
27
|
return JSON.stringify(token,null,space);
|