@vope/utils 1.6.0-bate.7 → 1.6.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 (75) hide show
  1. package/dist/clamp.js +3 -23
  2. package/dist/classnames.js +7 -27
  3. package/dist/compare/version.js +3 -23
  4. package/dist/compare/weak-equal.js +5 -25
  5. package/dist/convert/json.js +3 -23
  6. package/dist/convert/object.js +3 -23
  7. package/dist/convert/strings.js +3 -23
  8. package/dist/desens.js +7 -27
  9. package/dist/encoding.js +3 -23
  10. package/dist/index.cjs.js +1265 -0
  11. package/dist/index.js +72 -102
  12. package/dist/input-regex.js +3 -23
  13. package/dist/is/class.js +3 -23
  14. package/dist/is/empty.js +4 -24
  15. package/dist/is/key.js +3 -23
  16. package/dist/is/null.js +3 -23
  17. package/dist/load/image.js +3 -23
  18. package/dist/memory/basic.js +5 -25
  19. package/dist/memory/list.js +5 -25
  20. package/dist/memory/power.js +7 -27
  21. package/dist/memory/simple.js +5 -25
  22. package/dist/neo4j-anchors.js +6 -26
  23. package/dist/neo4j.js +12 -32
  24. package/dist/once.js +3 -23
  25. package/dist/parse/num.js +5 -25
  26. package/dist/power/decon.js +3 -23
  27. package/dist/rotate/angle.js +4 -24
  28. package/dist/rotate/rad.js +3 -23
  29. package/dist/serialize/url-params.js +8 -28
  30. package/dist/style/css.js +7 -27
  31. package/dist/subscriber.js +5 -25
  32. package/dist/table/flex.js +3 -23
  33. package/dist/union.js +3 -23
  34. package/dist/url/join.js +3 -23
  35. package/dist/url/params.js +5 -25
  36. package/dist/wait.js +3 -23
  37. package/package.json +8 -8
  38. package/sub_storage/{offline.mjs → offline.cjs.js} +59 -27
  39. package/sub_storage/offline.js +15 -45
  40. package/sub_storage/package.json +2 -2
  41. package/dist/clamp.mjs +0 -11
  42. package/dist/classnames.mjs +0 -17
  43. package/dist/compare/version.mjs +0 -15
  44. package/dist/compare/weak-equal.mjs +0 -33
  45. package/dist/convert/json.mjs +0 -7
  46. package/dist/convert/object.mjs +0 -7
  47. package/dist/convert/strings.mjs +0 -7
  48. package/dist/desens.mjs +0 -51
  49. package/dist/encoding.mjs +0 -56
  50. package/dist/index.mjs +0 -73
  51. package/dist/input-regex.mjs +0 -8
  52. package/dist/is/class.mjs +0 -22
  53. package/dist/is/empty.mjs +0 -5
  54. package/dist/is/key.mjs +0 -4
  55. package/dist/is/null.mjs +0 -4
  56. package/dist/load/image.mjs +0 -11
  57. package/dist/memory/basic.mjs +0 -167
  58. package/dist/memory/list.mjs +0 -12
  59. package/dist/memory/power.mjs +0 -13
  60. package/dist/memory/simple.mjs +0 -94
  61. package/dist/neo4j-anchors.mjs +0 -169
  62. package/dist/neo4j.mjs +0 -161
  63. package/dist/once.mjs +0 -8
  64. package/dist/parse/num.mjs +0 -31
  65. package/dist/power/decon.mjs +0 -22
  66. package/dist/rotate/angle.mjs +0 -5
  67. package/dist/rotate/rad.mjs +0 -11
  68. package/dist/serialize/url-params.mjs +0 -53
  69. package/dist/style/css.mjs +0 -25
  70. package/dist/subscriber.mjs +0 -64
  71. package/dist/table/flex.mjs +0 -96
  72. package/dist/union.mjs +0 -47
  73. package/dist/url/join.mjs +0 -9
  74. package/dist/url/params.mjs +0 -8
  75. package/dist/wait.mjs +0 -4
@@ -1,53 +0,0 @@
1
- import { isString } from "lodash-es";
2
- import { isKey } from "../is/key";
3
- const cubes = {
4
- string: (text) => text,
5
- boolean: (text) => text === "true",
6
- number: (text) => Number(text),
7
- bigint: (text) => BigInt(text),
8
- date: (text) => new Date(text),
9
- regexp: (text) => new RegExp(text),
10
- null: () => null
11
- };
12
- const flats = {
13
- string: (data) => flatEncode(data),
14
- boolean: (data) => `${data}`,
15
- number: (data) => `${data}`,
16
- bigint: (data) => `${data}`,
17
- date: (data) => data.toJSON(),
18
- regexp: (data) => flatEncode(data.source),
19
- null: () => "null"
20
- };
21
- const cubeURLParams = (text, serializes) => {
22
- const params = new URLSearchParams(text);
23
- const result = {};
24
- for (const [key, value] of params) {
25
- const serialize = serializes[key];
26
- if (!serialize) continue;
27
- if (isString(serialize) && isKey(serialize, cubes)) {
28
- result[key] = cubes[serialize](value);
29
- } else {
30
- result[key] = serialize.cube(value);
31
- }
32
- }
33
- return result;
34
- };
35
- const re_flat = /\+/g;
36
- const flatEncode = (text) => text.replace(re_flat, () => "%2B");
37
- const flatURLParams = (data, serializes) => {
38
- const params = new URLSearchParams();
39
- for (const key in data) {
40
- const value = data[key];
41
- const serialize = serializes[key];
42
- if (!serialize) continue;
43
- params.append(
44
- key,
45
- isString(serialize) && isKey(serialize, flats) ? flats[serialize](value) : serialize.flat(value)
46
- );
47
- }
48
- return params.toString();
49
- };
50
- export {
51
- cubeURLParams,
52
- flatURLParams
53
- };
@@ -1,25 +0,0 @@
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
- };
@@ -1,64 +0,0 @@
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
- };
@@ -1,96 +0,0 @@
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.mjs DELETED
@@ -1,47 +0,0 @@
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
- };
package/dist/url/join.mjs DELETED
@@ -1,9 +0,0 @@
1
- const re = /([^:])\/{2,}/g;
2
- const joinPaths = (...list) => {
3
- const { length } = list;
4
- if (length === 0) return "";
5
- return length === 1 ? list[0] : list.join("/").replace(re, ($0, $1) => `${$1}/`);
6
- };
7
- export {
8
- joinPaths
9
- };
@@ -1,8 +0,0 @@
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.mjs DELETED
@@ -1,4 +0,0 @@
1
- const wait = (delay = 0) => new Promise((resolve) => setTimeout(resolve, delay));
2
- export {
3
- wait
4
- };