reaxes-utils 2.0.7 → 2.0.9

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/changelog.md CHANGED
@@ -1,3 +1,5 @@
1
+ # 2.0.8
2
+ Fixed d.ts declaration in package.json
1
3
  # 2.0.6
2
4
  Fixed types
3
5
  # 2.0.5
package/package.json CHANGED
@@ -1,22 +1,16 @@
1
1
  {
2
2
  "name": "reaxes-utils",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "main": "esm/index.js",
5
5
  "module": "esm/index.js",
6
6
  "exports": {
7
7
  ".": {
8
- "import": "./esm/index.js"
8
+ "import": "./esm/index.js",
9
+ "types": "./types/index.d.ts"
9
10
  },
10
11
  "./react-hooks": {
11
- "import": "./esm/react-hooks/index.js"
12
+ "import": "./esm/react-hooks/index.js",
13
+ "types": "./types/react-hooks/index.d.ts"
12
14
  }
13
- },
14
- "typesVersions": {
15
- "*": {
16
- "react-hooks": [
17
- "./types/react-hooks/index.d.ts"
18
- ]
19
- }
20
- },
21
- "types": "./types/index.d.ts"
15
+ }
22
16
  }
@@ -1,4 +1,17 @@
1
1
  /// <reference types="react" />
2
+ /**
3
+ * 优雅的条件渲染器
4
+ * @example
5
+ * <If condition = {true}> 将会渲染出来 </If>
6
+ * <If condition = {() => false}> 将不会渲染出来 </If> ;
7
+ * <If condition = {() => false}>
8
+ * <>condition为<b>true</b>时会渲染</>
9
+ * {Else}
10
+ * <>condition为<b>false</b>时会渲染</>
11
+ * </If> ;
12
+ * @param children {ReactNode} 要条件渲染的 ReactNode ;
13
+ * @param condition {boolean | function : boolean} ;
14
+ */
2
15
  export declare const If: {
3
16
  ({ children, condition }: {
4
17
  children: any;
@@ -1,6 +1,18 @@
1
1
  export declare const assert: <Expect extends unknown, List extends any[]>(expected: Expect, expressionList: List, consoleWarn?: boolean) => boolean;
2
+ /**
3
+ * 组断言函数
4
+ *
5
+ * @example exp1 === true && exp2 === true && exp3 ==> assertTrue([exp1,exp2,exp3]) === true
6
+ * @param array 一组表达式
7
+ */
2
8
  export declare const assertTrue: (array: any, consoleWarn?: boolean) => boolean;
9
+ /**每一组断言均为false时返回true*/
3
10
  export declare const assertFalse: (array: any, consoleWarn?: boolean) => boolean;
11
+ /**
12
+ * 断言-一组表达式中只要有一个符合@param1则返回true
13
+ * @example
14
+ assert1of(false , [true,true,false,true]) -> true
15
+ */
4
16
  export declare const assert1of: <Expected extends unknown, ExpressionList extends any[]>(expected: Expected, expressionList: ExpressionList, consoleWarn?: boolean) => boolean;
5
17
  export declare const assert1ofTrue: (expressionList: any, consoleWarn?: boolean) => boolean;
6
18
  export declare const assert1ofFalse: (expressionList: any, consoleWarn?: boolean) => boolean;
@@ -1 +1,5 @@
1
+ /**
2
+ * 延迟执行回调函数,在同步任务执行后尽快异步执行
3
+ * 用于延后初始化函数,调整代码顺序等.
4
+ */
1
5
  export declare const asyncCall: <T extends Function>(callback: T) => void;
@@ -5,5 +5,8 @@ type crayon = ((css: Partial<CSSStyleDeclaration>) => (...logs: any[]) => void)
5
5
  } & {
6
6
  [key in string]: (...any: any[]) => any;
7
7
  };
8
+ /**
9
+ * todo 实现crayon({...css}).group('xxx')
10
+ */
8
11
  export declare const crayon: crayon;
9
12
  export {};
@@ -1 +1,4 @@
1
+ /**
2
+ * @description 成对使用数据 value也可是callback
3
+ */
1
4
  export declare const makePair: <I, F extends (value: I) => any>(value: I, ...callbacks: F[]) => [I, ...ReturnType<F>[]];
@@ -1,6 +1,14 @@
1
+ /**
2
+ * @description 将字符串qs转换为对象(暂不支持多层嵌套)||注意:中文key-value需要decodeURIComponent!!!
3
+ * @param str 要转换的字符串,不传默认是获取href query对象
4
+ */
1
5
  type ret = {
2
6
  [p: string]: string;
3
7
  };
4
8
  export declare const decodeQueryString: <result extends ret>(str?: string) => ret;
9
+ /**
10
+ * 将对象转换为queryString不带问号(暂不支持多层嵌套)
11
+ * @return {string} a=1&b=2
12
+ */
5
13
  export declare const encodeQueryString: (source: object) => string;
6
14
  export {};
@@ -1,3 +1,8 @@
1
+ /**
2
+ * 准确的计时器 , 原型方法可以被链式调用
3
+ *
4
+ * @format
5
+ */
1
6
  export declare const Timer: {
2
7
  new (): {
3
8
  "__#1@#subscribeList": any[];
@@ -6,6 +11,10 @@ export declare const Timer: {
6
11
  "__#1@#currentTimeout": any;
7
12
  "__#1@#status": boolean;
8
13
  start: (time: any) => void | any;
14
+ /**
15
+ * 订阅的每过1s就执行一次函数[相同引用的函数只会订阅一次]
16
+ * @param callback {function(number):*}
17
+ */
9
18
  subscribe(callback: any): any;
10
19
  unsubscribe(callback: any): any;
11
20
  destroy(): void;
@@ -1 +1,23 @@
1
+ /**
2
+ * @description
3
+ * 动态import模块,一般用于在reaxel中于不同的运行时环境加载不同的模块使用
4
+ * @example Basic using:
5
+ * orxImport({
6
+ * react : import('react'),
7
+ * reactDOM : import('react-dom')
8
+ * }).then(({react,reactDOM}) => {
9
+ * react.createElement();
10
+ * reactDOM.createRoot();
11
+ * });
12
+ * @example Use in reaxel:
13
+ * if(Runtime === 'wap'){
14
+ * orxImport({antdMobile : import('antd-mobile')}).then(({antdMobile}}) => {
15
+ * antdMobile.message.success();
16
+ * })
17
+ * }else if(Runtime === 'pc'){
18
+ * orxImport({antd:import('antd')}).then(({antd}}) => {
19
+ * antd.message.success();
20
+ * })
21
+ * }
22
+ */
1
23
  export declare const xImport: <T extends { [p in keyof T]: T[p]; }>(imports: T) => Promise<{ [p_1 in keyof T]: Awaited<T[p_1]>; }>;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @format
3
+ * @description 生成一个pending状态的promise
4
+ */
1
5
  export declare const xPromise: <T>(callback?: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) => Promise<T> & {
2
6
  resolve: (value: T | PromiseLike<T>) => void;
3
7
  reject: (reason?: any) => void;