utils-lib-js 1.4.1 → 1.4.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.
@@ -166,11 +166,11 @@ var classDecorator = function (params) {
166
166
  };
167
167
  exports.classDecorator = classDecorator;
168
168
  var stringToJson = function (target) {
169
- if ((0, index_js_1.getType)(target) !== "string") return {};
169
+ if ((0, index_js_1.getType)(target) !== "string") return null;
170
170
  try {
171
171
  return JSON.parse(target);
172
172
  } catch (error) {
173
- return {};
173
+ return null;
174
174
  }
175
175
  };
176
176
  exports.stringToJson = stringToJson;
@@ -26,7 +26,7 @@ export declare type ICreateObject = <T, U extends T>(source: T) => U;
26
26
  export declare type IInherit = <T extends Function>(source: T, target?: Function) => Function;
27
27
  export declare type IGetInstance = (classProto: IInstance<FunctionConstructor>, overwrite?: boolean, ...params: any[]) => Function;
28
28
  export declare type IClassDecorator = (params: IObject<any>) => <TFunction extends Function>(target: TFunction) => void;
29
- export declare type IStringToJson = (target: string) => IObject<any>;
29
+ export declare type IStringToJson = (target: string) => IObject<any> | null;
30
30
  export declare type IJsonToString = (target: IObject<any>) => string;
31
31
  export declare type IThrottle = (fn: Function, time: number) => (...args: any[]) => void;
32
32
  export declare type IDebounce = (fn: Function, time: number) => (...args: any[]) => void;
@@ -151,11 +151,11 @@ export var classDecorator = function (params) {
151
151
  };
152
152
  };
153
153
  export var stringToJson = function (target) {
154
- if (getType(target) !== "string") return {};
154
+ if (getType(target) !== "string") return null;
155
155
  try {
156
156
  return JSON.parse(target);
157
157
  } catch (error) {
158
- return {};
158
+ return null;
159
159
  }
160
160
  };
161
161
  export var jsonToString = function (target) {
@@ -26,7 +26,7 @@ export declare type ICreateObject = <T, U extends T>(source: T) => U;
26
26
  export declare type IInherit = <T extends Function>(source: T, target?: Function) => Function;
27
27
  export declare type IGetInstance = (classProto: IInstance<FunctionConstructor>, overwrite?: boolean, ...params: any[]) => Function;
28
28
  export declare type IClassDecorator = (params: IObject<any>) => <TFunction extends Function>(target: TFunction) => void;
29
- export declare type IStringToJson = (target: string) => IObject<any>;
29
+ export declare type IStringToJson = (target: string) => IObject<any> | null;
30
30
  export declare type IJsonToString = (target: IObject<any>) => string;
31
31
  export declare type IThrottle = (fn: Function, time: number) => (...args: any[]) => void;
32
32
  export declare type IDebounce = (fn: Function, time: number) => (...args: any[]) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utils-lib-js",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "JavaScript工具函数,封装的一些常用的js函数",
5
5
  "main": "./dist/common/index.js",
6
6
  "types": "./dist/common/index.d.ts",