49623336a388afbaa339b69e0acb0e9760f9bd46.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, ObjectUtil, _crd;
  4. _export("ObjectUtil", void 0);
  5. return {
  6. setters: [function (_cc) {
  7. _cclegacy = _cc.cclegacy;
  8. }],
  9. execute: function () {
  10. _crd = true;
  11. _cclegacy._RF.push({}, "86827QLFSRM7Zojsx0WqWuQ", "ObjectUtil", undefined);
  12. /*
  13. * @Author: dgflash
  14. * @Date: 2022-07-26 15:29:57
  15. * @LastEditors: dgflash
  16. * @LastEditTime: 2022-09-02 12:07:54
  17. */
  18. /** 对象工具 */
  19. _export("ObjectUtil", ObjectUtil = class ObjectUtil {
  20. /**
  21. * 判断指定的值是否为对象
  22. * @param value 值
  23. */
  24. static isObject(value) {
  25. return Object.prototype.toString.call(value) === '[object Object]';
  26. }
  27. /**
  28. * 深拷贝
  29. * @param target 目标
  30. */
  31. static deepCopy(target) {
  32. if (target == null || typeof target !== 'object') {
  33. return target;
  34. }
  35. var result = null;
  36. if (target instanceof Date) {
  37. result = new Date();
  38. result.setTime(target.getTime());
  39. return result;
  40. }
  41. if (target instanceof Array) {
  42. result = [];
  43. for (var i = 0, length = target.length; i < length; i++) {
  44. result[i] = this.deepCopy(target[i]);
  45. }
  46. return result;
  47. }
  48. if (target instanceof Object) {
  49. result = {};
  50. for (var key in target) {
  51. if (target.hasOwnProperty(key)) {
  52. result[key] = this.deepCopy(target[key]);
  53. }
  54. }
  55. return result;
  56. }
  57. console.warn("\u4E0D\u652F\u6301\u7684\u7C7B\u578B\uFF1A" + result);
  58. }
  59. /**
  60. * 拷贝对象
  61. * @param target 目标
  62. */
  63. static copy(target) {
  64. return JSON.parse(JSON.stringify(target));
  65. }
  66. });
  67. _cclegacy._RF.pop();
  68. _crd = false;
  69. }
  70. };
  71. });
  72. //# sourceMappingURL=49623336a388afbaa339b69e0acb0e9760f9bd46.js.map