@whitesev/utils 1.3.8 → 1.4.0

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.
@@ -117,7 +117,7 @@ export declare interface Vue2Context extends AnyObject {
117
117
  afterEach: ((to: Vue2Context["$route"], from: Vue2Context["$route"]) => void) | null;
118
118
  };
119
119
  $ssrContext: AnyObject;
120
- $watch: (key: string | string[], handler: (this: any, newVal: any, oldVal: any) => void, options?: {
120
+ $watch: (key: string | string[] | (() => any), handler: (this: any, newVal: any, oldVal: any) => void, options?: {
121
121
  immediate?: boolean;
122
122
  deep?: boolean;
123
123
  }) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/node/index.esm.js",
package/src/Utils.ts CHANGED
@@ -133,7 +133,7 @@ export declare interface Vue2Context extends AnyObject {
133
133
  $ssrContext: AnyObject;
134
134
 
135
135
  $watch: (
136
- key: string | string[],
136
+ key: string | string[] | (() => any),
137
137
  handler: (this: any, newVal: any, oldVal: any) => void,
138
138
  options?: {
139
139
  immediate?: boolean;
@@ -4724,6 +4724,9 @@ class Utils {
4724
4724
  if (typeof checkObj === "function") {
4725
4725
  obj = checkObj();
4726
4726
  }
4727
+ if (typeof obj !== "object") {
4728
+ return;
4729
+ }
4727
4730
  if (
4728
4731
  (typeof checkPropertyName === "function" && checkPropertyName(obj)) ||
4729
4732
  Reflect.has(obj, checkPropertyName as string)