iv-npm 1.0.29 → 1.0.32

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": "iv-npm",
3
- "version": "1.0.29",
3
+ "version": "1.0.32",
4
4
  "description": "公共通用包",
5
5
  "author": "Mr.Cong",
6
6
  "license": "ISC",
@@ -18,4 +18,9 @@ declare function findTree<T extends {
18
18
  children?: T[];
19
19
  }>(id: string, list: T[], idName?: any): any;
20
20
 
21
- export { arrToTree, findTree, tranListToTreeData };
21
+ /**
22
+ * 检查对象是否为普通对象(使用“{}”或“new Object”创建)
23
+ * */
24
+ declare function isPlainObject(obj: object): boolean;
25
+
26
+ export { arrToTree, findTree, isPlainObject, tranListToTreeData };
@@ -44,8 +44,23 @@ function findTree(id, list, idName) {
44
44
  fn(id, list, idName);
45
45
  return result;
46
46
  }
47
+
48
+ // utils/obj/judge.ts
49
+ function isPlainObject(obj) {
50
+ let proto, Ctor;
51
+ if (!obj || toString.call(obj) !== "[object Object]") {
52
+ return false;
53
+ }
54
+ proto = Object.getPrototypeOf(obj);
55
+ if (!proto) {
56
+ return true;
57
+ }
58
+ Ctor = {}.hasOwnProperty.call(proto, "constructor") && proto.constructor;
59
+ return typeof Ctor === "function" && {}.hasOwnProperty.toString.call(Ctor) === {}.hasOwnProperty.toString.call(Object);
60
+ }
47
61
  export {
48
62
  arrToTree,
49
63
  findTree,
64
+ isPlainObject,
50
65
  tranListToTreeData
51
66
  };