@ceale/util 1.12.5 → 1.13.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.
package/README.md CHANGED
@@ -40,4 +40,6 @@
40
40
  - class `QuadraticBezier`
41
41
  - class `CubicBezier`
42
42
  - `error.ts`
43
- - tryCatch()
43
+ - tryCatch()
44
+ - `type.ts`
45
+ - assert()
package/dist/cjs/index.js CHANGED
@@ -40,6 +40,7 @@ __export(exports_src, {
40
40
  debounce: () => debounce,
41
41
  cubicCurve: () => cubicCurve,
42
42
  css: () => css,
43
+ assert: () => assert,
43
44
  QuadraticBezier: () => QuadraticBezier,
44
45
  CubicBezier: () => CubicBezier
45
46
  });
@@ -255,12 +256,6 @@ var throttle = (func, delay) => {
255
256
  };
256
257
  };
257
258
  // src/bezier.ts
258
- class BezierError extends Error {
259
- constructor(message) {
260
- super(message);
261
- this.name = "BezierError";
262
- }
263
- }
264
259
  var quadraticCurve;
265
260
  ((quadraticCurve) => {
266
261
  quadraticCurve.solveX = (p1, t) => {
@@ -346,7 +341,7 @@ class QuadraticBezier {
346
341
  this.p1 = p1;
347
342
  this.accuracy = accuracy;
348
343
  if (this.p1[0] < 0 || this.p1[0] > 1) {
349
- throw new BezierError("控制点P1的x坐标必须在[0, 1]之间");
344
+ throw new TypeError("控制点P1的x坐标必须在[0, 1]之间");
350
345
  }
351
346
  if (accuracy !== -1) {
352
347
  this.accuracy = 10 ** accuracy;
@@ -382,10 +377,10 @@ class CubicBezier {
382
377
  this.p2 = p2;
383
378
  this.accuracy = accuracy;
384
379
  if (this.p1[0] < 0 || this.p1[0] > 1) {
385
- throw new BezierError("控制点P1的x坐标必须在[0, 1]之间");
380
+ throw new TypeError("控制点P1的x坐标必须在[0, 1]之间");
386
381
  }
387
382
  if (this.p2[0] < 0 || this.p2[0] > 1) {
388
- throw new BezierError("控制点P2的x坐标必须在[0, 1]之间");
383
+ throw new TypeError("控制点P2的x坐标必须在[0, 1]之间");
389
384
  }
390
385
  if (accuracy !== -1) {
391
386
  this.accuracy = 10 ** accuracy;
@@ -425,3 +420,5 @@ var tryCatch = (parameter) => {
425
420
  }
426
421
  throw new TypeError("参数类型错误,应为 Promise 或函数");
427
422
  };
423
+ // src/type.ts
424
+ var assert = (v) => {};
package/dist/esm/index.js CHANGED
@@ -208,12 +208,6 @@ var throttle = (func, delay) => {
208
208
  };
209
209
  };
210
210
  // src/bezier.ts
211
- class BezierError extends Error {
212
- constructor(message) {
213
- super(message);
214
- this.name = "BezierError";
215
- }
216
- }
217
211
  var quadraticCurve;
218
212
  ((quadraticCurve) => {
219
213
  quadraticCurve.solveX = (p1, t) => {
@@ -299,7 +293,7 @@ class QuadraticBezier {
299
293
  this.p1 = p1;
300
294
  this.accuracy = accuracy;
301
295
  if (this.p1[0] < 0 || this.p1[0] > 1) {
302
- throw new BezierError("控制点P1的x坐标必须在[0, 1]之间");
296
+ throw new TypeError("控制点P1的x坐标必须在[0, 1]之间");
303
297
  }
304
298
  if (accuracy !== -1) {
305
299
  this.accuracy = 10 ** accuracy;
@@ -335,10 +329,10 @@ class CubicBezier {
335
329
  this.p2 = p2;
336
330
  this.accuracy = accuracy;
337
331
  if (this.p1[0] < 0 || this.p1[0] > 1) {
338
- throw new BezierError("控制点P1的x坐标必须在[0, 1]之间");
332
+ throw new TypeError("控制点P1的x坐标必须在[0, 1]之间");
339
333
  }
340
334
  if (this.p2[0] < 0 || this.p2[0] > 1) {
341
- throw new BezierError("控制点P2的x坐标必须在[0, 1]之间");
335
+ throw new TypeError("控制点P2的x坐标必须在[0, 1]之间");
342
336
  }
343
337
  if (accuracy !== -1) {
344
338
  this.accuracy = 10 ** accuracy;
@@ -378,6 +372,8 @@ var tryCatch = (parameter) => {
378
372
  }
379
373
  throw new TypeError("参数类型错误,应为 Promise 或函数");
380
374
  };
375
+ // src/type.ts
376
+ var assert = (v) => {};
381
377
  export {
382
378
  waitSync,
383
379
  wait,
@@ -390,6 +386,7 @@ export {
390
386
  debounce,
391
387
  cubicCurve,
392
388
  css,
389
+ assert,
393
390
  QuadraticBezier,
394
391
  CubicBezier
395
392
  };
@@ -6,3 +6,4 @@ export * from "./time";
6
6
  export * from "./task";
7
7
  export * from "./bezier";
8
8
  export * from "./error";
9
+ export * from "./type";
@@ -0,0 +1,34 @@
1
+ declare global {
2
+ interface Object {
3
+ deepAssign<T, U>(target: T, source: U, options?: DeepAssignOptions): T & U;
4
+ deepAssign<T, U, V>(target: T, source1: U, source2: V, options?: DeepAssignOptions): T & U & V;
5
+ deepAssign<T, U, V, W>(target: T, source1: U, source2: V, source3: W, options?: DeepAssignOptions): T & U & V & W;
6
+ deepAssign(target: any, ...sources: any[]): any;
7
+ }
8
+ }
9
+ interface DeepAssignOptions {
10
+ /**
11
+ * 合并深度:
12
+ * - true: 无限深度
13
+ * - false: 浅层合并 (等同于 Object.assign)
14
+ * - number: 指定最大深度
15
+ * @default true
16
+ */
17
+ deep?: boolean | number;
18
+ /**
19
+ * 是否覆盖目标对象属性:
20
+ * - true: 源对象属性覆盖目标对象
21
+ * - false: 只合并目标对象没有的属性
22
+ * @default true
23
+ */
24
+ overwrite?: boolean;
25
+ /**
26
+ * 数组合并策略:
27
+ * - 'merge': (默认)合并数组项 (递归合并数组元素)
28
+ * - 'concat': 连接数组
29
+ * - 'replace': 替换整个数组
30
+ * @default 'replace'
31
+ */
32
+ arrayStrategy?: 'replace' | 'merge' | 'concat';
33
+ }
34
+ export {};
@@ -0,0 +1 @@
1
+ export declare const assert: <T = any>(v: any) => asserts v is T;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ceale/util",
3
3
  "author": "Ceale",
4
- "version": "1.12.5",
4
+ "version": "1.13.0",
5
5
  "module": "index.ts",
6
6
  "type": "module",
7
7
  "main": "dist/esm/index.js",