@flowlist/js-core 1.7.6 → 2.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.
- package/dist/index.d.ts +4 -1
- package/dist/js-core.es.js +592 -1
- package/dist/js-core.umd.js +1 -1
- package/package.json +17 -16
- package/src/actions.ts +31 -51
- package/src/setters.ts +24 -38
- package/src/types.ts +2 -22
- package/src/utils.ts +10 -5
- package/dist/src/actions.d.ts +0 -5
- package/dist/src/enum.d.ts +0 -32
- package/dist/src/index.d.ts +0 -4
- package/dist/src/setters.d.ts +0 -3
- package/dist/src/types.d.ts +0 -117
- package/dist/src/utils.d.ts +0 -58
- package/dist/tests/unit/api.d.ts +0 -68
- package/dist/tests/unit/env.d.ts +0 -20
- package/dist/tests/unit/item-factory.d.ts +0 -23
- package/src/index.ts +0 -4
package/dist/src/types.d.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
export declare type objectKey = string | number;
|
|
2
|
-
export declare type keyMap = Record<objectKey, any>;
|
|
3
|
-
export declare type morphArray = any[];
|
|
4
|
-
export declare type fieldResult = morphArray | keyMap;
|
|
5
|
-
export declare type defaultField = {
|
|
6
|
-
result: fieldResult;
|
|
7
|
-
noMore: boolean;
|
|
8
|
-
nothing: boolean;
|
|
9
|
-
loading: boolean;
|
|
10
|
-
error: null | Error;
|
|
11
|
-
extra: null | any;
|
|
12
|
-
fetched: boolean;
|
|
13
|
-
page: number;
|
|
14
|
-
total: number;
|
|
15
|
-
};
|
|
16
|
-
export declare type fetchTypes = 'jump' | 'sinceId' | 'page' | 'seenIds' | 'auto';
|
|
17
|
-
export declare type fieldKeys = 'result' | 'noMore' | 'nothing' | 'loading' | 'error' | 'extra' | 'page' | 'total';
|
|
18
|
-
export declare type generateFieldProps = {
|
|
19
|
-
func: string | (() => {});
|
|
20
|
-
type: fetchTypes;
|
|
21
|
-
query: keyMap;
|
|
22
|
-
};
|
|
23
|
-
export declare type generateParamsType = {
|
|
24
|
-
field: defaultField;
|
|
25
|
-
uniqueKey: string;
|
|
26
|
-
query: keyMap;
|
|
27
|
-
type: fetchTypes;
|
|
28
|
-
};
|
|
29
|
-
export declare type generateParamsResp = {
|
|
30
|
-
seen_ids?: string;
|
|
31
|
-
since_id?: objectKey;
|
|
32
|
-
is_up?: 0 | 1;
|
|
33
|
-
page?: number;
|
|
34
|
-
};
|
|
35
|
-
export declare type setterFuncParams = {
|
|
36
|
-
key: string;
|
|
37
|
-
type: number;
|
|
38
|
-
value: any;
|
|
39
|
-
callback?: (obj?: keyMap) => void;
|
|
40
|
-
};
|
|
41
|
-
export declare type initStateType = {
|
|
42
|
-
getter: (str: string) => defaultField;
|
|
43
|
-
setter: (obj: setterFuncParams) => void;
|
|
44
|
-
func: string | (() => {});
|
|
45
|
-
type: fetchTypes;
|
|
46
|
-
query?: keyMap;
|
|
47
|
-
opts?: keyMap;
|
|
48
|
-
};
|
|
49
|
-
export declare type cacheType = {
|
|
50
|
-
get: ({ key }: {
|
|
51
|
-
key: string;
|
|
52
|
-
}) => Promise<any>;
|
|
53
|
-
set: ({ key, value, timeout }: {
|
|
54
|
-
key: string;
|
|
55
|
-
value: any;
|
|
56
|
-
timeout?: number;
|
|
57
|
-
}) => Promise<any>;
|
|
58
|
-
del: ({ key }: {
|
|
59
|
-
key: string;
|
|
60
|
-
}) => void;
|
|
61
|
-
};
|
|
62
|
-
export declare type initDataType = {
|
|
63
|
-
getter: (str: string) => defaultField;
|
|
64
|
-
setter: (obj: setterFuncParams) => void;
|
|
65
|
-
cache: cacheType;
|
|
66
|
-
func: string | (() => {});
|
|
67
|
-
type: fetchTypes;
|
|
68
|
-
query?: keyMap;
|
|
69
|
-
api: keyMap;
|
|
70
|
-
cacheTimeout: number;
|
|
71
|
-
uniqueKey: string;
|
|
72
|
-
callback: (obj?: keyMap) => void;
|
|
73
|
-
};
|
|
74
|
-
export declare type loadMoreType = {
|
|
75
|
-
getter: (str: string) => defaultField;
|
|
76
|
-
setter: (obj: setterFuncParams) => void;
|
|
77
|
-
cache: cacheType;
|
|
78
|
-
func: string | (() => {});
|
|
79
|
-
type: fetchTypes;
|
|
80
|
-
query?: keyMap;
|
|
81
|
-
api: keyMap;
|
|
82
|
-
cacheTimeout: number;
|
|
83
|
-
uniqueKey: string;
|
|
84
|
-
errorRetry: boolean;
|
|
85
|
-
callback: (obj?: keyMap) => void;
|
|
86
|
-
};
|
|
87
|
-
export declare type updateStateType = {
|
|
88
|
-
getter: (str: string) => defaultField;
|
|
89
|
-
setter: (obj: setterFuncParams) => void;
|
|
90
|
-
cache: cacheType;
|
|
91
|
-
func: string | (() => {});
|
|
92
|
-
type: fetchTypes;
|
|
93
|
-
query?: keyMap;
|
|
94
|
-
method: string;
|
|
95
|
-
value: any;
|
|
96
|
-
id: string | number | objectKey[];
|
|
97
|
-
changeKey: string;
|
|
98
|
-
cacheTimeout: number;
|
|
99
|
-
uniqueKey: string;
|
|
100
|
-
};
|
|
101
|
-
export declare type setDataType = {
|
|
102
|
-
getter: (str: string) => defaultField;
|
|
103
|
-
setter: (obj: setterFuncParams) => void;
|
|
104
|
-
cache: cacheType;
|
|
105
|
-
data: any;
|
|
106
|
-
fieldName: string;
|
|
107
|
-
type: fetchTypes;
|
|
108
|
-
fromLocal: boolean;
|
|
109
|
-
cacheTimeout: number;
|
|
110
|
-
page: number;
|
|
111
|
-
insertBefore: boolean;
|
|
112
|
-
};
|
|
113
|
-
export declare type setErrorType = {
|
|
114
|
-
setter: (obj: setterFuncParams) => void;
|
|
115
|
-
fieldName: string;
|
|
116
|
-
error: null | Error;
|
|
117
|
-
};
|
package/dist/src/utils.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { objectKey, keyMap, morphArray, fieldResult, defaultField, fetchTypes, fieldKeys, generateFieldProps, generateParamsType, generateParamsResp } from './types';
|
|
2
|
-
export declare const generateDefaultField: (opts?: {}) => defaultField;
|
|
3
|
-
/**
|
|
4
|
-
* 根据参数生成 field 的 namespace
|
|
5
|
-
* @param {string} func
|
|
6
|
-
* @param {string} type
|
|
7
|
-
* @param {object} query
|
|
8
|
-
* @return {string}
|
|
9
|
-
*/
|
|
10
|
-
export declare const generateFieldName: ({ func, type, query }: generateFieldProps) => string;
|
|
11
|
-
/**
|
|
12
|
-
* 根据 key 从 object 里拿 value
|
|
13
|
-
* @param {object} field
|
|
14
|
-
* @param {string} keys
|
|
15
|
-
* @return {*}
|
|
16
|
-
*/
|
|
17
|
-
export declare const getObjectDeepValue: (field: keyMap, keys: string | string[]) => any;
|
|
18
|
-
export declare const updateObjectDeepValue: (field: keyMap, changeKey: string, value: any) => void;
|
|
19
|
-
export declare const searchValueByKey: (result: fieldResult, id: objectKey, key: objectKey) => any;
|
|
20
|
-
/**
|
|
21
|
-
* 通过 id 匹配返回数组中某个对象的 index
|
|
22
|
-
* @param {int|string} itemId
|
|
23
|
-
* @param {array} fieldArr
|
|
24
|
-
* @param {int|string} changingKey
|
|
25
|
-
* @return {number}
|
|
26
|
-
*/
|
|
27
|
-
export declare const computeMatchedItemIndex: (itemId: objectKey, fieldArr: morphArray, changingKey: objectKey) => number;
|
|
28
|
-
export declare const combineArrayData: (fieldArray: any[], value: fieldResult, changingKey: string) => void;
|
|
29
|
-
/**
|
|
30
|
-
* 判断参数是否为数组
|
|
31
|
-
* @param {object|array} data
|
|
32
|
-
* @return {boolean}
|
|
33
|
-
*/
|
|
34
|
-
export declare const isArray: (data: any) => boolean;
|
|
35
|
-
/**
|
|
36
|
-
* 设置一个响应式的数据到对象上
|
|
37
|
-
* @param {object} field
|
|
38
|
-
* @param {string} key
|
|
39
|
-
* @param {array|object} value
|
|
40
|
-
* @param {string} type
|
|
41
|
-
* @param {boolean} insertBefore
|
|
42
|
-
*/
|
|
43
|
-
export declare const setReactivityField: (field: defaultField, key: fieldKeys, value: any, type: fetchTypes, insertBefore: boolean) => void;
|
|
44
|
-
/**
|
|
45
|
-
* 计算一个数据列的长度
|
|
46
|
-
* @param {array|object} data
|
|
47
|
-
* @return {number}
|
|
48
|
-
*/
|
|
49
|
-
export declare const computeResultLength: (data: fieldResult) => number;
|
|
50
|
-
/**
|
|
51
|
-
* 拼接请求的参数
|
|
52
|
-
* @param {object} field
|
|
53
|
-
* @param {string} uniqueKey
|
|
54
|
-
* @param {object} query
|
|
55
|
-
* @param {string} type
|
|
56
|
-
* @return {object}
|
|
57
|
-
*/
|
|
58
|
-
export declare const generateRequestParams: ({ field, uniqueKey, query, type }: generateParamsType) => generateParamsResp;
|
package/dist/tests/unit/api.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export declare const testArrData: () => {
|
|
2
|
-
result: {
|
|
3
|
-
id: number;
|
|
4
|
-
slug: string;
|
|
5
|
-
obj: {
|
|
6
|
-
key: string;
|
|
7
|
-
};
|
|
8
|
-
arr: {
|
|
9
|
-
id: number;
|
|
10
|
-
text: string;
|
|
11
|
-
}[];
|
|
12
|
-
}[];
|
|
13
|
-
no_more: boolean;
|
|
14
|
-
total: number;
|
|
15
|
-
};
|
|
16
|
-
export declare const testCommentData: () => {
|
|
17
|
-
result: {
|
|
18
|
-
parent_id: number;
|
|
19
|
-
content: string;
|
|
20
|
-
children: {
|
|
21
|
-
sub_id: number;
|
|
22
|
-
content: string;
|
|
23
|
-
}[];
|
|
24
|
-
}[];
|
|
25
|
-
};
|
|
26
|
-
export declare const testArrFunc: () => Promise<unknown>;
|
|
27
|
-
export declare const testError: () => Promise<unknown>;
|
|
28
|
-
export declare const getListByPage: ({ page, count }: {
|
|
29
|
-
page: any;
|
|
30
|
-
count: any;
|
|
31
|
-
}) => Promise<unknown>;
|
|
32
|
-
export declare const getObjectByPage: ({ page, count }: {
|
|
33
|
-
page: any;
|
|
34
|
-
count: any;
|
|
35
|
-
}) => Promise<unknown>;
|
|
36
|
-
export declare const getListBySinceId: ({ since_id, is_up, count }: {
|
|
37
|
-
since_id: any;
|
|
38
|
-
is_up: any;
|
|
39
|
-
count: any;
|
|
40
|
-
}) => Promise<unknown>;
|
|
41
|
-
export declare const getListByJump: ({ page, count }: {
|
|
42
|
-
page: any;
|
|
43
|
-
count: any;
|
|
44
|
-
}) => Promise<unknown>;
|
|
45
|
-
export declare const getListWithError: ({ page, count }: {
|
|
46
|
-
page: any;
|
|
47
|
-
count: any;
|
|
48
|
-
}) => Promise<unknown>;
|
|
49
|
-
export declare const getListByFirstLoading: ({ page, count }: {
|
|
50
|
-
page: any;
|
|
51
|
-
count: any;
|
|
52
|
-
}) => Promise<unknown>;
|
|
53
|
-
export declare const getListByFirstError: ({ page, count }: {
|
|
54
|
-
page: any;
|
|
55
|
-
count: any;
|
|
56
|
-
}) => Promise<unknown>;
|
|
57
|
-
export declare const getListByLastId: ({ last_id, count }: {
|
|
58
|
-
last_id: any;
|
|
59
|
-
count: any;
|
|
60
|
-
}) => Promise<unknown>;
|
|
61
|
-
export declare const getListBySeenIds: ({ seen_ids, count }: {
|
|
62
|
-
seen_ids: any;
|
|
63
|
-
count: any;
|
|
64
|
-
}) => Promise<unknown>;
|
|
65
|
-
export declare const getListByNothing: ({ page, count }: {
|
|
66
|
-
page: any;
|
|
67
|
-
count: any;
|
|
68
|
-
}) => Promise<unknown>;
|
package/dist/tests/unit/env.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const getter: (fieldName: any) => any;
|
|
2
|
-
export declare const setter: ({ key, type, value, callback }: {
|
|
3
|
-
key: any;
|
|
4
|
-
type: any;
|
|
5
|
-
value: any;
|
|
6
|
-
callback: any;
|
|
7
|
-
}) => void;
|
|
8
|
-
export declare const cache: {
|
|
9
|
-
set({ key, value, timeout }: {
|
|
10
|
-
key: any;
|
|
11
|
-
value: any;
|
|
12
|
-
timeout: any;
|
|
13
|
-
}): Promise<unknown>;
|
|
14
|
-
get({ key }: {
|
|
15
|
-
key: any;
|
|
16
|
-
}): Promise<unknown>;
|
|
17
|
-
del({ key }: {
|
|
18
|
-
key: any;
|
|
19
|
-
}): void;
|
|
20
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
get(count: any): {
|
|
3
|
-
id: number;
|
|
4
|
-
style: {
|
|
5
|
-
color: string;
|
|
6
|
-
};
|
|
7
|
-
width: number;
|
|
8
|
-
height: number;
|
|
9
|
-
data: any;
|
|
10
|
-
like: boolean;
|
|
11
|
-
} | {
|
|
12
|
-
id: number;
|
|
13
|
-
style: {
|
|
14
|
-
color: string;
|
|
15
|
-
};
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
data: any;
|
|
19
|
-
like: boolean;
|
|
20
|
-
}[];
|
|
21
|
-
getRandomColor(): string;
|
|
22
|
-
};
|
|
23
|
-
export default _default;
|
package/src/index.ts
DELETED