@vope/utils 1.6.0-bate.2 → 1.6.0-bate.3
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/clamp.d.ts +4 -0
- package/dist/clamp.mjs +11 -0
- package/dist/classnames.d.ts +7 -0
- package/dist/classnames.mjs +17 -0
- package/dist/compare/version.d.ts +5 -0
- package/dist/compare/version.mjs +15 -0
- package/dist/compare/weak-equal.d.ts +4 -0
- package/dist/compare/weak-equal.mjs +33 -0
- package/dist/convert/json.d.ts +12 -0
- package/dist/convert/json.mjs +7 -0
- package/dist/convert/object.d.ts +12 -0
- package/dist/convert/object.mjs +7 -0
- package/dist/convert/strings.d.ts +6 -0
- package/dist/convert/strings.mjs +7 -0
- package/dist/desens.d.ts +40 -0
- package/dist/desens.mjs +51 -0
- package/dist/encoding.d.ts +9 -0
- package/dist/encoding.mjs +56 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1361 -0
- package/dist/index.mjs +73 -0
- package/dist/input-regex.d.ts +12 -0
- package/dist/input-regex.mjs +8 -0
- package/dist/is/class.d.ts +4 -0
- package/dist/is/class.mjs +22 -0
- package/dist/is/empty.d.ts +4 -0
- package/dist/is/empty.mjs +5 -0
- package/dist/is/key.d.ts +4 -0
- package/dist/is/key.mjs +4 -0
- package/dist/is/null.d.ts +4 -0
- package/dist/is/null.mjs +4 -0
- package/dist/load/image.d.ts +5 -0
- package/dist/load/image.mjs +11 -0
- package/dist/memory/basic.d.ts +79 -0
- package/dist/memory/basic.mjs +167 -0
- package/dist/memory/list.d.ts +8 -0
- package/dist/memory/list.mjs +12 -0
- package/dist/memory/power.d.ts +8 -0
- package/dist/memory/power.mjs +13 -0
- package/dist/memory/simple.d.ts +60 -0
- package/dist/memory/simple.mjs +94 -0
- package/dist/neo4j-anchors.d.ts +50 -0
- package/dist/neo4j-anchors.mjs +169 -0
- package/dist/neo4j.d.ts +82 -0
- package/dist/neo4j.mjs +161 -0
- package/dist/once.d.ts +6 -0
- package/dist/once.mjs +8 -0
- package/dist/parse/num.d.ts +8 -0
- package/dist/parse/num.mjs +31 -0
- package/dist/power/decon.d.ts +9 -0
- package/dist/power/decon.mjs +22 -0
- package/dist/rotate/angle.d.ts +8 -0
- package/dist/rotate/angle.mjs +5 -0
- package/dist/rotate/rad.d.ts +8 -0
- package/dist/rotate/rad.mjs +11 -0
- package/dist/serialize/url-params.d.ts +43 -0
- package/dist/serialize/url-params.mjs +53 -0
- package/dist/storage/offline.d.ts +51 -0
- package/dist/style/css.d.ts +9 -0
- package/dist/style/css.mjs +25 -0
- package/dist/subscriber.d.ts +11 -0
- package/dist/subscriber.mjs +64 -0
- package/dist/table/flex.d.ts +43 -0
- package/dist/table/flex.mjs +96 -0
- package/dist/union.d.ts +34 -0
- package/dist/union.mjs +47 -0
- package/dist/url/join.d.ts +4 -0
- package/dist/url/join.mjs +9 -0
- package/dist/url/params.d.ts +8 -0
- package/dist/url/params.mjs +8 -0
- package/dist/wait.d.ts +4 -0
- package/dist/wait.mjs +4 -0
- package/package.json +3 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Properties, PropertiesHyphen } from 'csstype';
|
|
2
|
+
export interface CSSProperties extends Properties<string | number>, PropertiesHyphen<string | number> {
|
|
3
|
+
[v: `--${string}`]: string | number | undefined;
|
|
4
|
+
}
|
|
5
|
+
export type StyleValue = false | null | undefined | string | CSSProperties | Array<StyleValue>;
|
|
6
|
+
/**
|
|
7
|
+
* Css合并
|
|
8
|
+
*/
|
|
9
|
+
export declare const css: (...args: StyleValue[]) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isString } from "lodash-es";
|
|
2
|
+
import { isNull } from "../is/null";
|
|
3
|
+
const hump = /[A-Z]/g;
|
|
4
|
+
const css = (...args) => {
|
|
5
|
+
const list = [];
|
|
6
|
+
for (let i = 0; i < args.length; i++) {
|
|
7
|
+
const data = args[i];
|
|
8
|
+
if (!data) continue;
|
|
9
|
+
if (isString(data)) {
|
|
10
|
+
list.push(data);
|
|
11
|
+
} else if (Array.isArray(data)) {
|
|
12
|
+
const result = css(...data);
|
|
13
|
+
result && list.push(result);
|
|
14
|
+
} else {
|
|
15
|
+
for (const key in data) {
|
|
16
|
+
const value = data[key];
|
|
17
|
+
isNull(value) || list.push(`${key.replace(hump, ($0) => "-" + $0.toLocaleLowerCase())}: ${value}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return list.join(";");
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
css
|
|
25
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type SModel = Record<keyof any, (...args: any[]) => void>;
|
|
2
|
+
/**
|
|
3
|
+
* 订阅
|
|
4
|
+
*/
|
|
5
|
+
export default class Subscriber<T extends SModel> {
|
|
6
|
+
#private;
|
|
7
|
+
$on<K extends keyof T>(name: K, listener: T[K]): this;
|
|
8
|
+
$once<K extends keyof T>(name: K, listener: T[K]): this;
|
|
9
|
+
$emit<K extends keyof T>(name: K, ...args: Parameters<T[K]>): this;
|
|
10
|
+
$off<K extends keyof T>(name: K, listener?: T[K]): this;
|
|
11
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { hash8strings } from "./convert/strings";
|
|
2
|
+
class Subscriber {
|
|
3
|
+
#listeners = {};
|
|
4
|
+
#once = {};
|
|
5
|
+
$on(name, listener) {
|
|
6
|
+
const listeners = this.#listeners;
|
|
7
|
+
if (name in listeners) {
|
|
8
|
+
listeners[name].push(listener);
|
|
9
|
+
} else {
|
|
10
|
+
listeners[name] = [listener];
|
|
11
|
+
}
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
$once(name, listener) {
|
|
15
|
+
this.$on(name, listener);
|
|
16
|
+
const index = this.#listeners[name].length - 1;
|
|
17
|
+
const once = this.#once;
|
|
18
|
+
if (name in once) {
|
|
19
|
+
once[name].push(index);
|
|
20
|
+
} else {
|
|
21
|
+
once[name] = [index];
|
|
22
|
+
}
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
$emit(name, ...args) {
|
|
26
|
+
const listeners = this.#listeners[name];
|
|
27
|
+
if (!listeners) return this;
|
|
28
|
+
const once = hash8strings(this.#once[name] || []);
|
|
29
|
+
this.#listeners[name] = listeners.reduce((list, listener, index) => {
|
|
30
|
+
listener(...args);
|
|
31
|
+
index in once || list.push(listener);
|
|
32
|
+
return list;
|
|
33
|
+
}, []);
|
|
34
|
+
delete this.#once[name];
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
$off(name, listener) {
|
|
38
|
+
const listeners = this.#listeners;
|
|
39
|
+
const once = this.#once;
|
|
40
|
+
if (name in listeners === false) return this;
|
|
41
|
+
if (listener) {
|
|
42
|
+
let count;
|
|
43
|
+
listeners[name].some((value, index) => {
|
|
44
|
+
if (value === listener) {
|
|
45
|
+
count = index;
|
|
46
|
+
listeners[name].splice(index, 1);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}) && once[name].some((value, index) => {
|
|
50
|
+
if (value === count) {
|
|
51
|
+
listeners[name].splice(index, 1);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
delete listeners[name];
|
|
57
|
+
delete this.#once[name];
|
|
58
|
+
}
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
Subscriber as default
|
|
64
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用一维的方式存储二维表
|
|
3
|
+
*/
|
|
4
|
+
export declare class FlexTable<T> {
|
|
5
|
+
#private;
|
|
6
|
+
/**
|
|
7
|
+
* 行数
|
|
8
|
+
*/
|
|
9
|
+
get rowspan(): number;
|
|
10
|
+
/**
|
|
11
|
+
* 总数据长度
|
|
12
|
+
*/
|
|
13
|
+
get length(): number;
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* 创建新行
|
|
17
|
+
*/
|
|
18
|
+
newline(): this;
|
|
19
|
+
push(value: T): this;
|
|
20
|
+
/**
|
|
21
|
+
* 替换指定位置的数据
|
|
22
|
+
* @description 指定位置必需为有效位置
|
|
23
|
+
*/
|
|
24
|
+
replace(rowspan: number, colspan: number, value: T): this;
|
|
25
|
+
/**
|
|
26
|
+
* 从指定位置开始移除或者替换/添加元素
|
|
27
|
+
* @description 指定位置必需为有效位置
|
|
28
|
+
*/
|
|
29
|
+
splice(rowspan: number, colspan: number, deleteCount: number, ...values: T[]): this;
|
|
30
|
+
pop(): T | null;
|
|
31
|
+
/**
|
|
32
|
+
* 遍历数据
|
|
33
|
+
*/
|
|
34
|
+
each(callback: (value: T, rowspan: number, colspan: number) => boolean | void): void;
|
|
35
|
+
/**
|
|
36
|
+
* 反序遍历数据
|
|
37
|
+
*/
|
|
38
|
+
reverseEach(callback: (value: T, rowspan: number, colspan: number) => boolean | void): void;
|
|
39
|
+
/**
|
|
40
|
+
* 清空数据
|
|
41
|
+
*/
|
|
42
|
+
clear(): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
class FlexTable {
|
|
2
|
+
#data = [];
|
|
3
|
+
/**
|
|
4
|
+
* 行数
|
|
5
|
+
*/
|
|
6
|
+
get rowspan() {
|
|
7
|
+
return this.#data.length;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 总数据长度
|
|
11
|
+
*/
|
|
12
|
+
get length() {
|
|
13
|
+
return this.#data.reduce((length, list) => length + list.length, 0);
|
|
14
|
+
}
|
|
15
|
+
constructor() {
|
|
16
|
+
this.newline();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 创建新行
|
|
20
|
+
*/
|
|
21
|
+
newline() {
|
|
22
|
+
this.#data.push([]);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
push(value) {
|
|
26
|
+
const rowspan = this.#data.length;
|
|
27
|
+
rowspan || this.newline();
|
|
28
|
+
this.#data[rowspan - 1].push(value);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 替换指定位置的数据
|
|
33
|
+
* @description 指定位置必需为有效位置
|
|
34
|
+
*/
|
|
35
|
+
replace(rowspan, colspan, value) {
|
|
36
|
+
const list = this.#data[rowspan];
|
|
37
|
+
list && colspan in list && (list[colspan] = value);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 从指定位置开始移除或者替换/添加元素
|
|
42
|
+
* @description 指定位置必需为有效位置
|
|
43
|
+
*/
|
|
44
|
+
splice(rowspan, colspan, deleteCount, ...values) {
|
|
45
|
+
const list = this.#data[rowspan];
|
|
46
|
+
list && colspan in list && list.splice(colspan, deleteCount, ...values);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
pop() {
|
|
50
|
+
const data = this.#data;
|
|
51
|
+
const rowspan = data.length;
|
|
52
|
+
if (!rowspan) return null;
|
|
53
|
+
const list = data[rowspan - 1];
|
|
54
|
+
if (list.length) {
|
|
55
|
+
return list.pop();
|
|
56
|
+
} else {
|
|
57
|
+
data.pop();
|
|
58
|
+
return this.pop();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 遍历数据
|
|
63
|
+
*/
|
|
64
|
+
each(callback) {
|
|
65
|
+
const data = this.#data;
|
|
66
|
+
outloop: for (let i = 0; i < data.length; i++) {
|
|
67
|
+
const list = data[i];
|
|
68
|
+
for (let j = 0; j < list.length; j++) {
|
|
69
|
+
if (callback(list[j], i, j) === false) break outloop;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 反序遍历数据
|
|
75
|
+
*/
|
|
76
|
+
reverseEach(callback) {
|
|
77
|
+
const data = this.#data;
|
|
78
|
+
outloop: for (let i = data.length; i; ) {
|
|
79
|
+
const list = data[--i];
|
|
80
|
+
for (let j = list.length; j; ) {
|
|
81
|
+
if (callback(list[--j], i, j) === false) break outloop;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 清空数据
|
|
87
|
+
*/
|
|
88
|
+
clear() {
|
|
89
|
+
if (this.#data.length) {
|
|
90
|
+
this.#data = [];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
FlexTable
|
|
96
|
+
};
|
package/dist/union.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Revise } from '@vope/types';
|
|
2
|
+
interface Result<Data, Option> {
|
|
3
|
+
data: Data;
|
|
4
|
+
option: Option;
|
|
5
|
+
}
|
|
6
|
+
type Raws<Primary extends string, Status extends string, Origin extends {
|
|
7
|
+
[key in Primary]: string;
|
|
8
|
+
}> = {
|
|
9
|
+
[P in Status]: Revise<Origin, Primary, P>;
|
|
10
|
+
};
|
|
11
|
+
type GetStatus<T> = T extends Union<any, any, any, any, any, infer S> ? S : never;
|
|
12
|
+
/**
|
|
13
|
+
* 数据联合(用于需要对加入的数据进行智能提示)
|
|
14
|
+
*/
|
|
15
|
+
export declare class Union<Primary extends string, Member extends string, Origin extends {
|
|
16
|
+
[key in Primary]: string;
|
|
17
|
+
}, Data extends unknown, Option extends unknown, Status extends Member | never = never> {
|
|
18
|
+
#private;
|
|
19
|
+
protected key: Primary;
|
|
20
|
+
private formatter;
|
|
21
|
+
get data(): Required<Record<Status, Data>>;
|
|
22
|
+
get options(): Required<Record<Status, Option>>;
|
|
23
|
+
constructor(key: Primary, formatter: (data: Origin) => Result<Data, Option>);
|
|
24
|
+
add<P extends Exclude<Member, Status>>(data: Revise<Origin, Primary, P>): Union<Primary, Member, Origin, Data, Option, Status | P> & Omit<this, keyof Union<Primary, Member, Origin, Data, Option, Status | P>>;
|
|
25
|
+
/**
|
|
26
|
+
* 获取原始数据
|
|
27
|
+
*/
|
|
28
|
+
getRaw<P extends Status>(key: P): Raws<Primary, Status, Origin>[P];
|
|
29
|
+
/**
|
|
30
|
+
* 从已有的联合中拷贝数据
|
|
31
|
+
*/
|
|
32
|
+
clone<T extends Union<Primary, string, Origin, Data, Option>, const P extends Exclude<GetStatus<T> & Member, Status>>(target: T, key: P | P[]): Union<Primary, Member, Origin, Data, Option, Status | P> & Omit<this, keyof Union<Primary, Member, Origin, Data, Option, Status | P>>;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
package/dist/union.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class Union {
|
|
2
|
+
constructor(key, formatter) {
|
|
3
|
+
this.key = key;
|
|
4
|
+
this.formatter = formatter;
|
|
5
|
+
}
|
|
6
|
+
#data = {};
|
|
7
|
+
#options = {};
|
|
8
|
+
#raws = {};
|
|
9
|
+
get data() {
|
|
10
|
+
return this.#data;
|
|
11
|
+
}
|
|
12
|
+
get options() {
|
|
13
|
+
return this.#options;
|
|
14
|
+
}
|
|
15
|
+
add(data) {
|
|
16
|
+
const key = data[this.key];
|
|
17
|
+
const result = this.formatter(data);
|
|
18
|
+
this.#raws[key] = data;
|
|
19
|
+
this.#data[key] = result.data;
|
|
20
|
+
this.#options[key] = result.option;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 获取原始数据
|
|
25
|
+
*/
|
|
26
|
+
getRaw(key) {
|
|
27
|
+
return this.#raws[key];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 从已有的联合中拷贝数据
|
|
31
|
+
*/
|
|
32
|
+
clone(target, key) {
|
|
33
|
+
const { data, options } = target;
|
|
34
|
+
const keys = Array.isArray(key) ? key : [key];
|
|
35
|
+
keys.forEach((key2) => {
|
|
36
|
+
if (key2 in data) {
|
|
37
|
+
this.#raws[key2] = target.getRaw(key2);
|
|
38
|
+
this.#data[key2] = data[key2];
|
|
39
|
+
this.#options[key2] = options[key2];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
Union
|
|
47
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Serializes } from '../serialize/url-params';
|
|
2
|
+
/**
|
|
3
|
+
* url拼接参数
|
|
4
|
+
* @param url
|
|
5
|
+
* @param params 需要让url携带的参数
|
|
6
|
+
* @param serializes 转换套件
|
|
7
|
+
*/
|
|
8
|
+
export declare const connectURLParams: <T extends object>(url: string, params: T, serializes: Serializes<T>) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { flatURLParams } from "../serialize/url-params";
|
|
2
|
+
const connectURLParams = (url, params, serializes) => {
|
|
3
|
+
const query = flatURLParams(params, serializes);
|
|
4
|
+
return query ? url.includes("?") ? url + "&" + query : url + "?" + query : url;
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
connectURLParams
|
|
8
|
+
};
|
package/dist/wait.d.ts
ADDED
package/dist/wait.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vope/utils",
|
|
3
|
-
"version": "1.6.0-bate.
|
|
3
|
+
"version": "1.6.0-bate.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,9 +36,8 @@
|
|
|
36
36
|
"author": "vope",
|
|
37
37
|
"license": "ISC",
|
|
38
38
|
"files": [
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"types"
|
|
39
|
+
"dist",
|
|
40
|
+
"sub_*"
|
|
42
41
|
],
|
|
43
42
|
"devDependencies": {
|
|
44
43
|
"@babel/parser": "^7.26.9",
|