@vope/utils 1.0.2 → 1.2.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 (58) hide show
  1. package/README.md +0 -5
  2. package/cjs/clamp.js +14 -0
  3. package/cjs/classnames.js +22 -0
  4. package/cjs/compare/version.js +21 -0
  5. package/cjs/compare/{value.js → weak-equal.js} +6 -6
  6. package/cjs/encoding.js +65 -0
  7. package/cjs/index.js +33 -5
  8. package/cjs/input-regex.js +10 -0
  9. package/cjs/is/class.js +1 -2
  10. package/cjs/memory/basic.js +148 -0
  11. package/cjs/memory/list.js +20 -0
  12. package/cjs/memory/power.js +19 -0
  13. package/cjs/once.js +15 -0
  14. package/cjs/power/decon.js +31 -0
  15. package/cjs/rotate/angle.js +14 -0
  16. package/cjs/rotate/rad.js +17 -0
  17. package/cjs/union.js +25 -0
  18. package/cjs/url/join.js +3 -4
  19. package/cjs/wait.js +6 -0
  20. package/lib/clamp.js +12 -0
  21. package/lib/classnames.js +20 -0
  22. package/lib/compare/version.js +19 -0
  23. package/lib/compare/{value.js → weak-equal.js} +6 -6
  24. package/lib/encoding.js +63 -0
  25. package/lib/index.js +17 -3
  26. package/lib/input-regex.js +8 -0
  27. package/lib/is/class.js +2 -1
  28. package/lib/memory/basic.js +142 -0
  29. package/lib/memory/list.js +14 -0
  30. package/lib/memory/power.js +13 -0
  31. package/lib/once.js +13 -0
  32. package/lib/power/decon.js +29 -0
  33. package/lib/rotate/angle.js +9 -0
  34. package/lib/rotate/rad.js +15 -0
  35. package/lib/union.js +22 -0
  36. package/lib/url/join.js +3 -2
  37. package/lib/wait.js +4 -0
  38. package/package.json +9 -10
  39. package/types/clamp.d.ts +5 -0
  40. package/types/classnames.d.ts +7 -0
  41. package/types/compare/version.d.ts +6 -0
  42. package/types/compare/weak-equal.d.ts +5 -0
  43. package/types/encoding.d.ts +16 -0
  44. package/types/index.d.ts +17 -3
  45. package/types/input-regex.d.ts +13 -0
  46. package/types/is/class.d.ts +2 -1
  47. package/types/memory/basic.d.ts +63 -0
  48. package/types/memory/list.d.ts +8 -0
  49. package/types/memory/power.d.ts +8 -0
  50. package/types/memory/type.d.ts +11 -0
  51. package/types/once.d.ts +7 -0
  52. package/types/power/decon.d.ts +9 -0
  53. package/types/rotate/angle.d.ts +9 -0
  54. package/types/rotate/rad.d.ts +9 -0
  55. package/types/union.d.ts +20 -0
  56. package/types/url/join.d.ts +2 -1
  57. package/types/wait.d.ts +5 -0
  58. package/types/compare/value.d.ts +0 -5
@@ -0,0 +1,8 @@
1
+ import MemoryBasic from './basic';
2
+ import { Memory } from './type';
3
+ /**
4
+ * 分类存储(基于2的n次幂之和构建唯一键进行存储)
5
+ */
6
+ export default class MemoryPower<V, Type extends Memory.Type = Memory.Type> extends MemoryBasic<V, number, Type> {
7
+ constructor(key: Memory.Pitch<V, Type>);
8
+ }
@@ -0,0 +1,11 @@
1
+ import { GetGivenProps } from '@vope/types'
2
+
3
+ export namespace Memory {
4
+ type Type = string | number
5
+
6
+ type Pitch<Data, Type> = (
7
+ Data extends object
8
+ ? GetGivenProps<Data, Type>
9
+ : never
10
+ ) | ((data: Data) => Type)
11
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 缓存函数返回值
3
+ * @param callback 运行返回值的函数
4
+ * @param thisArg 绑定到运行函数的this对象
5
+ */
6
+ declare const _default: <T extends (...args: any) => any>(func: T, thisArg?: any) => (...list: Parameters<T>) => ReturnType<T>;
7
+ export default _default;
@@ -0,0 +1,9 @@
1
+ type Sort = 'asc' | 'desc';
2
+ /**
3
+ * 解构多个2的正整数幂(两两不相等)之和
4
+ * @param sum 幂和
5
+ * @param sort 排序方式(默认降序)
6
+ * @description sum > 2**53则会因为精度问题计算报错
7
+ */
8
+ declare const deconPowersSum: (sum: number, sort?: Sort) => number[];
9
+ export default deconPowersSum;
@@ -0,0 +1,9 @@
1
+ import { _Point } from './rad';
2
+ /**
3
+ * 返回点被旋转指定角度后新的位置
4
+ * @param from 旋转点
5
+ * @param angle 旋转角度
6
+ * @param visit 旋转原点
7
+ */
8
+ declare const rotateAngle: (from: _Point, angle: number, visit?: _Point) => number[];
9
+ export default rotateAngle;
@@ -0,0 +1,9 @@
1
+ export type _Point = [number, number];
2
+ /**
3
+ * 返回点被旋转指定弧度后新的位置
4
+ * @param from 旋转点
5
+ * @param rad 旋转弧度
6
+ * @param visit 旋转原点
7
+ */
8
+ declare const rotateRad: (from: _Point, rad: number, visit?: _Point) => number[];
9
+ export default rotateRad;
@@ -0,0 +1,20 @@
1
+ import { Revise } from '@vope/types';
2
+ type IMap<K extends string, VV extends string, T extends {
3
+ [key in K]: string;
4
+ }> = {
5
+ [key in VV]?: T;
6
+ };
7
+ /**
8
+ * 数据联合(用于需要对加入的数据进行智能提示)
9
+ */
10
+ export default class Union<K extends string, VV extends string, T extends {
11
+ [key in K]: string;
12
+ }, L extends VV | never = never> {
13
+ #private;
14
+ private key;
15
+ private formater?;
16
+ get value(): Required<IMap<K, L, T>>;
17
+ constructor(key: K, formater?: ((data: T) => T) | undefined);
18
+ add<V extends Exclude<VV, L>>(data: Revise<T, K, V>): Union<K, VV, T, L | V>;
19
+ }
20
+ export {};
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * 实现多个路径拼接
3
3
  */
4
- export declare const joinURLs: (...list: string[]) => string;
4
+ declare const joinPaths: (...list: string[]) => string;
5
+ export default joinPaths;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 等待
3
+ */
4
+ declare const _default: (delay?: number) => Promise<void>;
5
+ export default _default;
@@ -1,5 +0,0 @@
1
- /**
2
- * 值比较(深度浅比较)
3
- */
4
- declare const compareValue: (from: any, to: any) => boolean;
5
- export default compareValue;