sculp-js 1.15.1 → 1.17.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.
Files changed (69) hide show
  1. package/dist/cjs/array.js +1 -1
  2. package/dist/cjs/async.js +1 -1
  3. package/dist/cjs/base64.js +1 -1
  4. package/dist/cjs/clipboard.js +1 -1
  5. package/dist/cjs/cloneDeep.js +1 -1
  6. package/dist/cjs/cookie.js +1 -1
  7. package/dist/cjs/date.js +1 -1
  8. package/dist/cjs/dom.js +1 -51
  9. package/dist/cjs/download.js +1 -1
  10. package/dist/cjs/file.js +1 -1
  11. package/dist/cjs/func.js +1 -1
  12. package/dist/cjs/index.js +3 -10
  13. package/dist/cjs/isEqual.js +210 -0
  14. package/dist/cjs/math.js +1 -1
  15. package/dist/cjs/number.js +1 -1
  16. package/dist/cjs/object.js +1 -1
  17. package/dist/cjs/path.js +1 -1
  18. package/dist/cjs/qs.js +1 -1
  19. package/dist/cjs/random.js +1 -1
  20. package/dist/cjs/string.js +1 -1
  21. package/dist/cjs/tooltip.js +1 -1
  22. package/dist/cjs/tree.js +1 -1
  23. package/dist/cjs/type.js +1 -1
  24. package/dist/cjs/unique.js +1 -1
  25. package/dist/cjs/url.js +1 -1
  26. package/dist/cjs/validator.js +1 -1
  27. package/dist/cjs/variable.js +1 -1
  28. package/dist/cjs/watermark.js +1 -1
  29. package/dist/esm/array.js +1 -1
  30. package/dist/esm/async.js +1 -1
  31. package/dist/esm/base64.js +1 -1
  32. package/dist/esm/clipboard.js +1 -1
  33. package/dist/esm/cloneDeep.js +1 -1
  34. package/dist/esm/cookie.js +1 -1
  35. package/dist/esm/date.js +1 -1
  36. package/dist/esm/dom.js +3 -52
  37. package/dist/esm/download.js +1 -1
  38. package/dist/esm/file.js +1 -1
  39. package/dist/esm/func.js +1 -1
  40. package/dist/esm/index.js +3 -5
  41. package/dist/esm/isEqual.js +208 -0
  42. package/dist/esm/math.js +1 -1
  43. package/dist/esm/number.js +1 -1
  44. package/dist/esm/object.js +1 -1
  45. package/dist/esm/path.js +1 -1
  46. package/dist/esm/qs.js +1 -1
  47. package/dist/esm/random.js +1 -1
  48. package/dist/esm/string.js +1 -1
  49. package/dist/esm/tooltip.js +1 -1
  50. package/dist/esm/tree.js +1 -1
  51. package/dist/esm/type.js +1 -1
  52. package/dist/esm/unique.js +1 -1
  53. package/dist/esm/url.js +1 -1
  54. package/dist/esm/validator.js +1 -1
  55. package/dist/esm/variable.js +1 -1
  56. package/dist/esm/watermark.js +1 -1
  57. package/dist/types/dom.d.ts +0 -10
  58. package/dist/types/index.d.ts +1 -2
  59. package/dist/types/isEqual.d.ts +15 -0
  60. package/dist/umd/index.min.js +2 -2
  61. package/package.json +9 -12
  62. package/dist/cjs/_virtual/_commonjsHelpers.js +0 -13
  63. package/dist/cjs/concurrentLimit.js +0 -179
  64. package/dist/cjs/easing.js +0 -72
  65. package/dist/cjs/node_modules/bezier-easing/src/index.js +0 -135
  66. package/dist/esm/concurrentLimit.js +0 -176
  67. package/dist/esm/easing.js +0 -67
  68. package/dist/types/concurrentLimit.d.ts +0 -65
  69. package/dist/types/easing.d.ts +0 -31
package/dist/cjs/array.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/async.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/date.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/dom.js CHANGED
@@ -1,13 +1,11 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
7
  'use strict';
8
8
 
9
- var array = require('./array.js');
10
- var easing = require('./easing.js');
11
9
  var object = require('./object.js');
12
10
  var string = require('./string.js');
13
11
  var type = require('./type.js');
@@ -66,53 +64,6 @@ const setStyle = (el, key, val) => {
66
64
  function getStyle(el, key) {
67
65
  return getComputedStyle(el).getPropertyValue(key);
68
66
  }
69
- function smoothScroll(options) {
70
- return new Promise(resolve => {
71
- const defaults = {
72
- el: document,
73
- to: 0,
74
- duration: 567,
75
- easing: 'ease'
76
- };
77
- const { el, to, duration, easing: easing$1 } = object.objectAssign(defaults, options);
78
- const htmlEl = document.documentElement;
79
- const bodyEl = document.body;
80
- const globalMode = el === window || el === document || el === htmlEl || el === bodyEl;
81
- const els = globalMode ? [htmlEl, bodyEl] : [el];
82
- const query = () => {
83
- let value = 0;
84
- array.arrayEach(els, el => {
85
- if ('scrollTop' in el) {
86
- value = el.scrollTop;
87
- return false;
88
- }
89
- });
90
- return value;
91
- };
92
- const update = val => {
93
- els.forEach(el => {
94
- if ('scrollTop' in el) {
95
- el.scrollTop = val;
96
- }
97
- });
98
- };
99
- let startTime;
100
- const startValue = query();
101
- const length = to - startValue;
102
- const easingFn = easing.easingFunctional(easing$1);
103
- const render = () => {
104
- const now = performance.now();
105
- const passingTime = startTime ? now - startTime : 0;
106
- const t = passingTime / duration;
107
- const p = easingFn(t);
108
- if (!startTime) startTime = now;
109
- update(startValue + length * p);
110
- if (t >= 1) resolve();
111
- else requestAnimationFrame(render);
112
- };
113
- render();
114
- });
115
- }
116
67
  /**
117
68
  * 获取元素样式属性的计算值
118
69
  * @param {HTMLElement} el
@@ -206,4 +157,3 @@ exports.hasClass = hasClass;
206
157
  exports.removeClass = removeClass;
207
158
  exports.select = select;
208
159
  exports.setStyle = setStyle;
209
- exports.smoothScroll = smoothScroll;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/file.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/func.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -32,8 +32,7 @@ var base64 = require('./base64.js');
32
32
  var validator = require('./validator.js');
33
33
  var variable = require('./variable.js');
34
34
  var cloneDeep = require('./cloneDeep.js');
35
- var easing = require('./easing.js');
36
- var concurrentLimit = require('./concurrentLimit.js');
35
+ var isEqual = require('./isEqual.js');
37
36
 
38
37
  exports.arrayEach = array.arrayEach;
39
38
  exports.arrayEachAsync = array.arrayEachAsync;
@@ -59,7 +58,6 @@ exports.hasClass = dom.hasClass;
59
58
  exports.removeClass = dom.removeClass;
60
59
  exports.select = dom.select;
61
60
  exports.setStyle = dom.setStyle;
62
- exports.smoothScroll = dom.smoothScroll;
63
61
  exports.crossOriginDownload = download.crossOriginDownload;
64
62
  exports.downloadBlob = download.downloadBlob;
65
63
  exports.downloadData = download.downloadData;
@@ -181,9 +179,4 @@ exports.parseVarFromString = variable.parseVarFromString;
181
179
  exports.replaceVarFromString = variable.replaceVarFromString;
182
180
  exports.uniqueSymbol = variable.uniqueSymbol;
183
181
  exports.cloneDeep = cloneDeep.cloneDeep;
184
- exports.easingFunctional = easing.easingFunctional;
185
- exports.easingStringify = easing.easingStringify;
186
- exports.getEasing = easing.getEasing;
187
- exports.setEasing = easing.setEasing;
188
- exports.ConcurrentExecutor = concurrentLimit.ConcurrentExecutor;
189
- exports.concurrentLimit = concurrentLimit.concurrentLimit;
182
+ exports.isEqual = isEqual.isEqual;
@@ -0,0 +1,210 @@
1
+ /*!
2
+ * sculp-js v1.17.0
3
+ * (c) 2023-present chandq
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ /**
10
+ * 使用位运算或常量定义常用 Tag,这里保持字符串以匹配 Object.prototype.toString
11
+ */
12
+ const TAGS = {
13
+ MAP: '[object Map]',
14
+ SET: '[object Set]',
15
+ DATE: '[object Date]',
16
+ REGEXP: '[object RegExp]',
17
+ SYMBOL: '[object Symbol]',
18
+ ARRAY_BUFFER: '[object ArrayBuffer]',
19
+ DATA_VIEW: '[object DataView]',
20
+ ARGUMENTS: '[object Arguments]'
21
+ };
22
+ const { toString, hasOwnProperty } = Object.prototype;
23
+ /**
24
+ * 获取对象类型的辅助函数
25
+ */
26
+ const getTag = value => toString.call(value);
27
+ /**
28
+ * @description 深度比较两个值是否相等(支持循环引用、各种内置对象类型)
29
+ * @performance
30
+ * 1. 快速路径:引用相等和 NaN 检查
31
+ * 2. 快速失败:优先比较 constructor、length 和 size
32
+ * 3. 惰性 getTag:仅在构造函数一致且非基础类型时获取详细类型
33
+ * * @example
34
+ * isEqual({ a: [1, 2] }, { a: [1, 2] }) // true
35
+ * isEqual(new Date(0), new Date(0)) // true
36
+ * isEqual(() => {}, () => {}) // false (不同引用)
37
+ * * @param value 要比较的值
38
+ * @param other 另一个要比较的值
39
+ * @returns {boolean} 是否深度相等
40
+ */
41
+ function isEqual(value, other) {
42
+ return baseIsEqual(value, other);
43
+ }
44
+ function baseIsEqual(value, other, stack = undefined) {
45
+ // 1. 引用相等 (快速路径)
46
+ if (value === other) {
47
+ return true;
48
+ }
49
+ // 2. 处理 NaN
50
+ if (value !== value && other !== other) {
51
+ return true;
52
+ }
53
+ // 3. 基本类型与空值检查
54
+ // 如果不是对象且不是函数,或者其中之一为 null,直接返回 false
55
+ if (typeof value !== 'object' || value === null || typeof other !== 'object' || other === null) {
56
+ return false;
57
+ }
58
+ // 4. 【性能优化】构造函数检查 (Fail Fast)
59
+ // 大多数不等的情况在这里就能被拦截,避免昂贵的 getTag 操作
60
+ // 注意:Object.create(null) 的 constructor 为 undefined
61
+ const ctorA = value.constructor;
62
+ const ctorB = other.constructor;
63
+ // 严格检查:
64
+ // 1. 解决 class A {} vs class B {} (结构相同但类不同) -> false
65
+ // 2. 解决 {} vs Object.create(null) -> false
66
+ if (ctorA !== ctorB) {
67
+ return false;
68
+ }
69
+ // 5. 初始化栈 (惰性初始化)
70
+ if (!stack) {
71
+ stack = new WeakMap();
72
+ }
73
+ // 6. 循环引用检查
74
+ if (stack.has(value)) {
75
+ return stack.get(value) === other;
76
+ }
77
+ stack.set(value, other);
78
+ // 7. 具体类型分发
79
+ // 此时我们确定 value 和 other 都是非 null 的对象/函数
80
+ const tagA = getTag(value);
81
+ const tagB = getTag(other); // 只有在 constructor 检查通过或存疑时才走到这里
82
+ if (tagA !== tagB) {
83
+ return false;
84
+ }
85
+ let result = false;
86
+ switch (tagA) {
87
+ case TAGS.DATE:
88
+ result = +value === +other;
89
+ break;
90
+ case TAGS.REGEXP:
91
+ result = '' + value === '' + other;
92
+ break;
93
+ case TAGS.SYMBOL:
94
+ result = Symbol.prototype.valueOf.call(value) === Symbol.prototype.valueOf.call(other);
95
+ break;
96
+ case TAGS.ARRAY_BUFFER:
97
+ result = deepCompareArrayBuffer(value, other);
98
+ break;
99
+ case TAGS.DATA_VIEW:
100
+ result = deepCompareDataView(value, other);
101
+ break;
102
+ case TAGS.MAP:
103
+ result = deepCompareMap(value, other, stack);
104
+ break;
105
+ case TAGS.SET:
106
+ result = deepCompareSet(value, other, stack);
107
+ break;
108
+ case TAGS.ARGUMENTS: // Arguments 视为对象或数组处理,通常 Tag 相同即可进入通用对象逻辑
109
+ default:
110
+ // 处理 Array, TypedArray, Object
111
+ if (Array.isArray(value) || ArrayBuffer.isView(value)) {
112
+ result = deepCompareArray(value, other, stack);
113
+ } else {
114
+ result = deepCompareObject(value, other, stack);
115
+ }
116
+ }
117
+ // 清理栈并非必须,因为是 WeakMap,但对于逻辑完整性可以不做操作
118
+ return result;
119
+ }
120
+ function deepCompareArray(a, b, stack) {
121
+ const len = a.length;
122
+ if (len !== b.length) {
123
+ return false;
124
+ }
125
+ // 倒序遍历,微小的性能提升
126
+ let i = len;
127
+ while (i--) {
128
+ if (!baseIsEqual(a[i], b[i], stack)) {
129
+ return false;
130
+ }
131
+ }
132
+ return true;
133
+ }
134
+ function deepCompareArrayBuffer(a, b) {
135
+ if (a.byteLength !== b.byteLength) return false;
136
+ const viewA = new Uint8Array(a);
137
+ const viewB = new Uint8Array(b);
138
+ let i = a.byteLength;
139
+ while (i--) {
140
+ if (viewA[i] !== viewB[i]) return false;
141
+ }
142
+ return true;
143
+ }
144
+ function deepCompareDataView(a, b) {
145
+ // 1. 长度不等直接退出
146
+ if (a.byteLength !== b.byteLength) return false;
147
+ // 2. 偏移量不等直接退出
148
+ if (a.byteOffset !== b.byteOffset) return false;
149
+ // 3. 比较底层的 buffer 内容
150
+ return deepCompareArrayBuffer(a.buffer, b.buffer);
151
+ }
152
+ function deepCompareMap(a, b, stack) {
153
+ if (a.size !== b.size) return false;
154
+ for (const [key, val] of a) {
155
+ // 性能关键:Map key 比较。如果 key 是对象,需要 O(N) 查找吗?
156
+ // 规范里 Map.get 使用 SameValueZero 算法。
157
+ // 如果 key 是引用类型且引用不同,Map 视为不同 key。
158
+ // isEqual 的语义下,如果 key 是两个内容相同的不同对象,我们是否应该视为匹配?
159
+ // Lodash 的处理:是的,Map 的 key 也进行深度比较。这非常慢 (O(N^2))。
160
+ // 这里为了性能,我们先尝试直接 get,只有拿不到时(可能 key 需要深度对比)才去遍历(Lodash 策略)。
161
+ // 但为了保持 "超高性能" 且符合大多数业务场景,我们假设 Map key 的引用关系必须一致,
162
+ // 或者仅仅对 primitive key 比较。
163
+ // 这里实现一个折中方案:直接 get,如果 undefined 再深度查。
164
+ const otherVal = b.get(key);
165
+ if (otherVal === undefined && !b.has(key)) {
166
+ // 只有当 key 是对象且在 b 中找不到引用相同的 key 时,才启用这个极慢的路径
167
+ // 真正的完全深度比较逻辑非常复杂,此处保持高性能假设:Key 引用必须匹配
168
+ return false;
169
+ }
170
+ if (!baseIsEqual(val, otherVal, stack)) {
171
+ return false;
172
+ }
173
+ }
174
+ return true;
175
+ }
176
+ function deepCompareSet(a, b, stack) {
177
+ if (a.size !== b.size) return false;
178
+ for (const val of a) {
179
+ if (b.has(val)) continue;
180
+ // Set 中存储对象时的深度比较 (O(N^2) 复杂度风险)
181
+ let matchFound = false;
182
+ for (const otherVal of b) {
183
+ if (baseIsEqual(val, otherVal, stack)) {
184
+ matchFound = true;
185
+ break;
186
+ }
187
+ }
188
+ if (!matchFound) return false;
189
+ }
190
+ return true;
191
+ }
192
+ function deepCompareObject(a, b, stack) {
193
+ // 使用 Reflect.ownKeys 以支持 Symbol,这是现代前端健壮性的关键
194
+ const keysA = Reflect.ownKeys(a);
195
+ const keysB = Reflect.ownKeys(b);
196
+ if (keysA.length !== keysB.length) {
197
+ return false;
198
+ }
199
+ for (let i = 0; i < keysA.length; i++) {
200
+ const key = keysA[i];
201
+ // 必须检查 b 是否也有这个 key(防止原型链干扰,虽然 Reflect.ownKeys 已过滤)
202
+ // 以及值的深度比较
203
+ if (!hasOwnProperty.call(b, key) || !baseIsEqual(a[key], b[key], stack)) {
204
+ return false;
205
+ }
206
+ }
207
+ return true;
208
+ }
209
+
210
+ exports.isEqual = isEqual;
package/dist/cjs/math.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/path.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/qs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/tree.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/type.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/cjs/url.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/esm/array.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/esm/async.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/esm/date.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/esm/dom.js CHANGED
@@ -1,12 +1,10 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
- import { arrayEach } from './array.js';
8
- import { easingFunctional } from './easing.js';
9
- import { objectEach, objectAssign } from './object.js';
7
+ import { objectEach } from './object.js';
10
8
  import { stringKebabCase } from './string.js';
11
9
  import { isObject, isString } from './type.js';
12
10
 
@@ -64,53 +62,6 @@ const setStyle = (el, key, val) => {
64
62
  function getStyle(el, key) {
65
63
  return getComputedStyle(el).getPropertyValue(key);
66
64
  }
67
- function smoothScroll(options) {
68
- return new Promise(resolve => {
69
- const defaults = {
70
- el: document,
71
- to: 0,
72
- duration: 567,
73
- easing: 'ease'
74
- };
75
- const { el, to, duration, easing } = objectAssign(defaults, options);
76
- const htmlEl = document.documentElement;
77
- const bodyEl = document.body;
78
- const globalMode = el === window || el === document || el === htmlEl || el === bodyEl;
79
- const els = globalMode ? [htmlEl, bodyEl] : [el];
80
- const query = () => {
81
- let value = 0;
82
- arrayEach(els, el => {
83
- if ('scrollTop' in el) {
84
- value = el.scrollTop;
85
- return false;
86
- }
87
- });
88
- return value;
89
- };
90
- const update = val => {
91
- els.forEach(el => {
92
- if ('scrollTop' in el) {
93
- el.scrollTop = val;
94
- }
95
- });
96
- };
97
- let startTime;
98
- const startValue = query();
99
- const length = to - startValue;
100
- const easingFn = easingFunctional(easing);
101
- const render = () => {
102
- const now = performance.now();
103
- const passingTime = startTime ? now - startTime : 0;
104
- const t = passingTime / duration;
105
- const p = easingFn(t);
106
- if (!startTime) startTime = now;
107
- update(startValue + length * p);
108
- if (t >= 1) resolve();
109
- else requestAnimationFrame(render);
110
- };
111
- render();
112
- });
113
- }
114
65
  /**
115
66
  * 获取元素样式属性的计算值
116
67
  * @param {HTMLElement} el
@@ -196,4 +147,4 @@ function select(element) {
196
147
  return selectedText;
197
148
  }
198
149
 
199
- export { addClass, getComputedCssVal, getStrWidthPx, getStyle, hasClass, removeClass, select, setStyle, smoothScroll };
150
+ export { addClass, getComputedCssVal, getStrWidthPx, getStyle, hasClass, removeClass, select, setStyle };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/esm/file.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.15.1
2
+ * sculp-js v1.17.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */