@oeos-components/utils 0.0.8 → 0.0.10

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/index.cjs CHANGED
@@ -1,11 +1,24 @@
1
1
  'use strict';
2
2
 
3
3
  const reactivity = require('@vue/reactivity');
4
- const lodashEs = require('lodash-es');
5
4
  const consola = require('consola');
6
5
  const elementPlus = require('element-plus');
7
6
 
8
7
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
8
+ function cloneDeep(source) {
9
+ if (!source && typeof source !== "object") {
10
+ throw new Error("error arguments", "cloneDeep");
11
+ }
12
+ const targetObj = source.constructor === Array ? [] : {};
13
+ Object.keys(source).forEach((keys) => {
14
+ if (source[keys] && typeof source[keys] === "object") {
15
+ targetObj[keys] = cloneDeep(source[keys]);
16
+ } else {
17
+ targetObj[keys] = source[keys];
18
+ }
19
+ });
20
+ return targetObj;
21
+ }
9
22
  const isString = (val) => typeof val === "string";
10
23
  const isStringNumber = (val) => {
11
24
  if (!isString(val)) {
@@ -215,9 +228,9 @@ function clone(data, times = 1) {
215
228
  data = reactivity.unref(data);
216
229
  }
217
230
  if (getType(data) !== "array") {
218
- return lodashEs.cloneDeep(data);
231
+ return cloneDeep(data);
219
232
  }
220
- const clonedData = lodashEs.cloneDeep(data);
233
+ const clonedData = cloneDeep(data);
221
234
  const result = [];
222
235
  for (let i = 0; i < times; i++) {
223
236
  result.push(...clonedData);
@@ -797,6 +810,7 @@ exports.$toast = $toast;
797
810
  exports.asyncWrapper = asyncWrapper;
798
811
  exports.clearStorage = clearStorage;
799
812
  exports.clone = clone;
813
+ exports.cloneDeep = cloneDeep;
800
814
  exports.confirm = confirm;
801
815
  exports.copy = copy;
802
816
  exports.debounce = debounce;
package/dist/index.d.cts CHANGED
@@ -2,6 +2,7 @@ import * as element_plus from 'element-plus';
2
2
  import { MessageOptions } from 'element-plus';
3
3
  import { Ref } from '@vue/reactivity';
4
4
 
5
+ declare function cloneDeep(source: any): {};
5
6
  /**
6
7
  * 现有方法如下
7
8
  * $toast(message, type: string | object = 'success', otherParams: object = {})
@@ -117,7 +118,7 @@ declare function merge(obj1: object, obj2: object): object;
117
118
  * clone(123) => 123
118
119
  * clone([1,2, {name: 'andy'}], 2) => [1, 2, {name: 'andy'}, 1, 2, {name: 'andy'}]
119
120
  */
120
- declare function clone(data: any, times?: number): any;
121
+ declare function clone(data: any, times?: number): {};
121
122
  /**
122
123
  * 格式化时间为年月日时分秒的格式, 格式可以自定义。
123
124
  * ① 时间戳10位和13位都可以转换成格式化的日期
@@ -362,4 +363,4 @@ declare function formatNewLines(str: any): any;
362
363
  * */
363
364
  declare function getVariable(propertyName: any): string;
364
365
 
365
- export { $toast, asyncWrapper, clearStorage, clone, confirm, copy, debounce, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatNewLines, formatThousands, formatTime, getStorage, getType, getVariable, isEmpty, isNumber, isString, isStringNumber, log, merge, notEmpty, processWidth, random, setStorage, sleep, throttle, toFixed, toLine, tryCatch, uuid, validForm, validate };
366
+ export { $toast, asyncWrapper, clearStorage, clone, cloneDeep, confirm, copy, debounce, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatNewLines, formatThousands, formatTime, getStorage, getType, getVariable, isEmpty, isNumber, isString, isStringNumber, log, merge, notEmpty, processWidth, random, setStorage, sleep, throttle, toFixed, toLine, tryCatch, uuid, validForm, validate };
package/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@ import * as element_plus from 'element-plus';
2
2
  import { MessageOptions } from 'element-plus';
3
3
  import { Ref } from '@vue/reactivity';
4
4
 
5
+ declare function cloneDeep(source: any): {};
5
6
  /**
6
7
  * 现有方法如下
7
8
  * $toast(message, type: string | object = 'success', otherParams: object = {})
@@ -117,7 +118,7 @@ declare function merge(obj1: object, obj2: object): object;
117
118
  * clone(123) => 123
118
119
  * clone([1,2, {name: 'andy'}], 2) => [1, 2, {name: 'andy'}, 1, 2, {name: 'andy'}]
119
120
  */
120
- declare function clone(data: any, times?: number): any;
121
+ declare function clone(data: any, times?: number): {};
121
122
  /**
122
123
  * 格式化时间为年月日时分秒的格式, 格式可以自定义。
123
124
  * ① 时间戳10位和13位都可以转换成格式化的日期
@@ -362,4 +363,4 @@ declare function formatNewLines(str: any): any;
362
363
  * */
363
364
  declare function getVariable(propertyName: any): string;
364
365
 
365
- export { $toast, asyncWrapper, clearStorage, clone, confirm, copy, debounce, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatNewLines, formatThousands, formatTime, getStorage, getType, getVariable, isEmpty, isNumber, isString, isStringNumber, log, merge, notEmpty, processWidth, random, setStorage, sleep, throttle, toFixed, toLine, tryCatch, uuid, validForm, validate };
366
+ export { $toast, asyncWrapper, clearStorage, clone, cloneDeep, confirm, copy, debounce, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatNewLines, formatThousands, formatTime, getStorage, getType, getVariable, isEmpty, isNumber, isString, isStringNumber, log, merge, notEmpty, processWidth, random, setStorage, sleep, throttle, toFixed, toLine, tryCatch, uuid, validForm, validate };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import * as element_plus from 'element-plus';
2
2
  import { MessageOptions } from 'element-plus';
3
3
  import { Ref } from '@vue/reactivity';
4
4
 
5
+ declare function cloneDeep(source: any): {};
5
6
  /**
6
7
  * 现有方法如下
7
8
  * $toast(message, type: string | object = 'success', otherParams: object = {})
@@ -117,7 +118,7 @@ declare function merge(obj1: object, obj2: object): object;
117
118
  * clone(123) => 123
118
119
  * clone([1,2, {name: 'andy'}], 2) => [1, 2, {name: 'andy'}, 1, 2, {name: 'andy'}]
119
120
  */
120
- declare function clone(data: any, times?: number): any;
121
+ declare function clone(data: any, times?: number): {};
121
122
  /**
122
123
  * 格式化时间为年月日时分秒的格式, 格式可以自定义。
123
124
  * ① 时间戳10位和13位都可以转换成格式化的日期
@@ -362,4 +363,4 @@ declare function formatNewLines(str: any): any;
362
363
  * */
363
364
  declare function getVariable(propertyName: any): string;
364
365
 
365
- export { $toast, asyncWrapper, clearStorage, clone, confirm, copy, debounce, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatNewLines, formatThousands, formatTime, getStorage, getType, getVariable, isEmpty, isNumber, isString, isStringNumber, log, merge, notEmpty, processWidth, random, setStorage, sleep, throttle, toFixed, toLine, tryCatch, uuid, validForm, validate };
366
+ export { $toast, asyncWrapper, clearStorage, clone, cloneDeep, confirm, copy, debounce, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatNewLines, formatThousands, formatTime, getStorage, getType, getVariable, isEmpty, isNumber, isString, isStringNumber, log, merge, notEmpty, processWidth, random, setStorage, sleep, throttle, toFixed, toLine, tryCatch, uuid, validForm, validate };
package/dist/index.mjs CHANGED
@@ -1,8 +1,21 @@
1
1
  import { unref, isRef, toRaw } from '@vue/reactivity';
2
- import { cloneDeep } from 'lodash-es';
3
2
  import { consola } from 'consola';
4
3
  import { ElMessage, ElMessageBox } from 'element-plus';
5
4
 
5
+ function cloneDeep(source) {
6
+ if (!source && typeof source !== "object") {
7
+ throw new Error("error arguments", "cloneDeep");
8
+ }
9
+ const targetObj = source.constructor === Array ? [] : {};
10
+ Object.keys(source).forEach((keys) => {
11
+ if (source[keys] && typeof source[keys] === "object") {
12
+ targetObj[keys] = cloneDeep(source[keys]);
13
+ } else {
14
+ targetObj[keys] = source[keys];
15
+ }
16
+ });
17
+ return targetObj;
18
+ }
6
19
  const isString = (val) => typeof val === "string";
7
20
  const isStringNumber = (val) => {
8
21
  if (!isString(val)) {
@@ -790,4 +803,4 @@ function getVariable(propertyName) {
790
803
  return res;
791
804
  }
792
805
 
793
- export { $toast, asyncWrapper, clearStorage, clone, confirm, copy, debounce, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatNewLines, formatThousands, formatTime, getStorage, getType, getVariable, isEmpty, isNumber, isString, isStringNumber, log, merge, notEmpty, processWidth, random, setStorage, sleep, throttle, toFixed, toLine, tryCatch, uuid, validForm, validate };
806
+ export { $toast, asyncWrapper, clearStorage, clone, cloneDeep, confirm, copy, debounce, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatNewLines, formatThousands, formatTime, getStorage, getType, getVariable, isEmpty, isNumber, isString, isStringNumber, log, merge, notEmpty, processWidth, random, setStorage, sleep, throttle, toFixed, toLine, tryCatch, uuid, validForm, validate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oeos-components/utils",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "utils of oeos-components",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",