devix 0.0.21 → 0.0.23-beta.1
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/README.md +25 -25
- package/dist/index.cjs.js +304 -156
- package/dist/index.esm.js +290 -156
- package/{dist/index.d.ts → index.d.ts} +18 -49
- package/lib/cache/index.cjs.js +38 -0
- package/lib/cache/index.esm.js +35 -0
- package/package.json +27 -34
- package/dist/index.umd.js +0 -158
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
//! format types
|
|
2
1
|
interface ITimerObj {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
year: string;
|
|
3
|
+
month: string;
|
|
4
|
+
day: string;
|
|
5
|
+
hours: string;
|
|
6
|
+
minutes: string;
|
|
7
|
+
seconds: string;
|
|
8
|
+
week: string;
|
|
9
|
+
weekNum: string;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
type TFormatTimer = (
|
|
14
|
-
cellValue: string | number | Date,
|
|
15
|
-
formatType?: string
|
|
16
|
-
) => string | ITimerObj
|
|
17
|
-
|
|
18
|
-
//! retalimit types
|
|
11
|
+
type TFormatTimer = (cellValue: string | number | Date, formatType?: string) => string | ITimerObj;
|
|
19
12
|
type ThrottleOptions = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
type TIsType = (type: string, target: any) => boolean
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
type
|
|
27
|
-
type TCases = [Tcase, Tcase]
|
|
28
|
-
type TTransGetParams = (params: IDataObject) => string
|
|
13
|
+
leading?: boolean;
|
|
14
|
+
trailing?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type TIsType = (type: string, target: any) => boolean;
|
|
17
|
+
type Tcase = 'upper' | 'lower';
|
|
18
|
+
type TCases = [Tcase, Tcase];
|
|
19
|
+
type TTransGetParams = (params: IDataObject) => string;
|
|
29
20
|
interface IDataObject {
|
|
30
|
-
|
|
21
|
+
[key: string]: any;
|
|
31
22
|
}
|
|
32
23
|
|
|
33
24
|
declare function currying(fn: Function): (this: any, ...args: any[]) => any;
|
|
@@ -38,28 +29,6 @@ declare const transformGetParams: TTransGetParams;
|
|
|
38
29
|
|
|
39
30
|
declare const isType: TIsType;
|
|
40
31
|
|
|
41
|
-
declare enum CacheType {
|
|
42
|
-
Local = 0,
|
|
43
|
-
Session = 1
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Encapsulate storage cache class
|
|
47
|
-
*
|
|
48
|
-
* @class StorageCache
|
|
49
|
-
* @template T
|
|
50
|
-
*/
|
|
51
|
-
declare class StorageCache<T = any> {
|
|
52
|
-
private storage;
|
|
53
|
-
constructor(type: CacheType);
|
|
54
|
-
getCache(key: string): T;
|
|
55
|
-
setCache(key: string, value: T): void;
|
|
56
|
-
updateCache(key: string, property: string, value: T): void;
|
|
57
|
-
deleteCache(key: string): void;
|
|
58
|
-
clearCache(): void;
|
|
59
|
-
}
|
|
60
|
-
declare const localCache: StorageCache<any>;
|
|
61
|
-
declare const sessionCache: StorageCache<any>;
|
|
62
|
-
|
|
63
32
|
declare function debounce<T extends (...args: any[]) => any>(callback: T, delay?: number, immediate?: boolean): ((...args: Parameters<T>) => Promise<ReturnType<T>>) & {
|
|
64
33
|
cancel: () => void;
|
|
65
34
|
};
|
|
@@ -81,4 +50,4 @@ declare function setTimer(execute: (...args: any[]) => any, delay?: number, imme
|
|
|
81
50
|
cancel: () => void;
|
|
82
51
|
}>;
|
|
83
52
|
|
|
84
|
-
export { SortType, bubblingSort, compose, currying, debounce, deepClone, formatTimer, insertStr, isType,
|
|
53
|
+
export { SortType, bubblingSort, compose, currying, debounce, deepClone, formatTimer, insertStr, isType, setTimer, shallowClone, stringCase, throttle, transformGetParams };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const isObject = (target) => target !== null && typeof target === "object";
|
|
4
|
+
var CacheType;
|
|
5
|
+
(function(CacheType2) {
|
|
6
|
+
CacheType2[CacheType2["Local"] = 0] = "Local";
|
|
7
|
+
CacheType2[CacheType2["Session"] = 1] = "Session";
|
|
8
|
+
})(CacheType || (CacheType = {}));
|
|
9
|
+
|
|
10
|
+
class StorageCache {
|
|
11
|
+
constructor(type) {
|
|
12
|
+
this.storage = type === CacheType.Local ? localStorage : sessionStorage;
|
|
13
|
+
}
|
|
14
|
+
getCache(key) {
|
|
15
|
+
const value = this.storage.getItem(key);
|
|
16
|
+
return value ? JSON.parse(value) : null;
|
|
17
|
+
}
|
|
18
|
+
setCache(key, value) {
|
|
19
|
+
this.storage.setItem(key, JSON.stringify(value));
|
|
20
|
+
}
|
|
21
|
+
updateCache(key, property, value) {
|
|
22
|
+
const cache = this.getCache(key);
|
|
23
|
+
if (!isObject(cache)) return;
|
|
24
|
+
cache[property] = value;
|
|
25
|
+
this.setCache(key, cache);
|
|
26
|
+
}
|
|
27
|
+
deleteCache(key) {
|
|
28
|
+
this.storage.removeItem(key);
|
|
29
|
+
}
|
|
30
|
+
clearCache() {
|
|
31
|
+
this.storage.clear();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const localCache = new StorageCache(CacheType.Local);
|
|
35
|
+
const sessionCache = new StorageCache(CacheType.Session);
|
|
36
|
+
|
|
37
|
+
exports.localCache = localCache;
|
|
38
|
+
exports.sessionCache = sessionCache;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const isObject = (target) => target !== null && typeof target === "object";
|
|
2
|
+
var CacheType;
|
|
3
|
+
(function(CacheType2) {
|
|
4
|
+
CacheType2[CacheType2["Local"] = 0] = "Local";
|
|
5
|
+
CacheType2[CacheType2["Session"] = 1] = "Session";
|
|
6
|
+
})(CacheType || (CacheType = {}));
|
|
7
|
+
|
|
8
|
+
class StorageCache {
|
|
9
|
+
constructor(type) {
|
|
10
|
+
this.storage = type === CacheType.Local ? localStorage : sessionStorage;
|
|
11
|
+
}
|
|
12
|
+
getCache(key) {
|
|
13
|
+
const value = this.storage.getItem(key);
|
|
14
|
+
return value ? JSON.parse(value) : null;
|
|
15
|
+
}
|
|
16
|
+
setCache(key, value) {
|
|
17
|
+
this.storage.setItem(key, JSON.stringify(value));
|
|
18
|
+
}
|
|
19
|
+
updateCache(key, property, value) {
|
|
20
|
+
const cache = this.getCache(key);
|
|
21
|
+
if (!isObject(cache)) return;
|
|
22
|
+
cache[property] = value;
|
|
23
|
+
this.setCache(key, cache);
|
|
24
|
+
}
|
|
25
|
+
deleteCache(key) {
|
|
26
|
+
this.storage.removeItem(key);
|
|
27
|
+
}
|
|
28
|
+
clearCache() {
|
|
29
|
+
this.storage.clear();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const localCache = new StorageCache(CacheType.Local);
|
|
33
|
+
const sessionCache = new StorageCache(CacheType.Session);
|
|
34
|
+
|
|
35
|
+
export { localCache, sessionCache };
|
package/package.json
CHANGED
|
@@ -1,82 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devix",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.23-beta.1",
|
|
5
5
|
"description": "Devix is a comprehensive, powerful, and compact JavaScript utility library.",
|
|
6
6
|
"author": "king-3 <w2196592083@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/OpenKnights/devix#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/OpenKnights/devix.git"
|
|
11
|
+
"url": "git+https://github.com/OpenKnights/devix.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/OpenKnights/devix/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"tools",
|
|
20
|
-
"develop"
|
|
17
|
+
"template",
|
|
18
|
+
"library"
|
|
21
19
|
],
|
|
22
20
|
"exports": {
|
|
23
21
|
".": {
|
|
22
|
+
"types": "./index.d.ts",
|
|
24
23
|
"import": "./dist/index.esm.js",
|
|
25
24
|
"require": "./dist/index.cjs.js"
|
|
26
25
|
}
|
|
27
26
|
},
|
|
27
|
+
"types": "./index.d.ts",
|
|
28
28
|
"main": "./dist/index.cjs.js",
|
|
29
29
|
"module": "./dist/index.esm.js",
|
|
30
|
-
"umd": "./dist/index.umd.js",
|
|
31
|
-
"types": "dist/index.d.ts",
|
|
32
30
|
"files": [
|
|
33
31
|
"dist/",
|
|
32
|
+
"lib/",
|
|
34
33
|
"package.json",
|
|
35
|
-
"README.md"
|
|
34
|
+
"README.md",
|
|
35
|
+
"index.d.ts"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "
|
|
39
|
-
"dev": "npx --yes tsx --watch example/index.ts",
|
|
38
|
+
"build": "rollup -c",
|
|
40
39
|
"test": "jest",
|
|
41
|
-
"lint": "eslint src/**/*.
|
|
42
|
-
"prettier": "prettier --config .prettierrc.json --write
|
|
43
|
-
"releases": "
|
|
40
|
+
"lint": "npx eslint src/**/*.ts && npx eslint test/**/*.ts && npx eslint types/**/*.ts",
|
|
41
|
+
"prettier": "npx prettier --config .prettierrc.json --write ./**/*.{ts,json}",
|
|
42
|
+
"releases": "pwsh publish.ps1",
|
|
44
43
|
"versihint": "npx bump"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"@babel/core": "^7.24.
|
|
48
|
-
"@babel/preset-env": "^7.24.
|
|
49
|
-
"@babel/preset-typescript": "^7.
|
|
46
|
+
"@babel/core": "^7.24.5",
|
|
47
|
+
"@babel/preset-env": "^7.24.5",
|
|
48
|
+
"@babel/preset-typescript": "^7.24.1",
|
|
49
|
+
"@rollup/plugin-alias": "^5.1.0",
|
|
50
50
|
"@rollup/plugin-babel": "^6.0.4",
|
|
51
51
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
52
52
|
"@rollup/plugin-json": "^6.1.0",
|
|
53
53
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
54
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
55
54
|
"@types/jest": "^29.5.12",
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"
|
|
59
|
-
"@types/koa-router": "^7.4.8",
|
|
60
|
-
"@types/node": "^20.12.7",
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
62
|
-
"@typescript-eslint/parser": "^7.3.1",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
56
|
+
"@typescript-eslint/parser": "^7.8.0",
|
|
57
|
+
"esbuild": "^0.21.0",
|
|
63
58
|
"eslint": "^8.57.0",
|
|
59
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
60
|
+
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
64
61
|
"eslint-config-prettier": "^9.1.0",
|
|
62
|
+
"eslint-plugin-import": "^2.29.1",
|
|
65
63
|
"eslint-plugin-prettier": "^5.1.3",
|
|
66
|
-
"fsxx": "^0.1.0",
|
|
67
64
|
"jest": "^29.7.0",
|
|
68
|
-
"koa": "^2.15.3",
|
|
69
|
-
"koa-bodyparser": "^4.4.1",
|
|
70
|
-
"koa-json": "^2.0.2",
|
|
71
|
-
"koa-router": "^12.0.1",
|
|
72
65
|
"prettier": "^3.2.5",
|
|
73
|
-
"rollup": "^4.
|
|
66
|
+
"rollup": "^4.17.2",
|
|
74
67
|
"rollup-plugin-dts": "^6.1.0",
|
|
68
|
+
"rollup-plugin-esbuild": "^6.1.1",
|
|
75
69
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
76
70
|
"ts-jest": "^29.1.2",
|
|
77
71
|
"tslib": "^2.6.2",
|
|
78
|
-
"typescript": "^5.4.
|
|
79
|
-
"version-bump-prompt": "^6.1.0"
|
|
80
|
-
"zx": "^7.2.3"
|
|
72
|
+
"typescript": "^5.4.5",
|
|
73
|
+
"version-bump-prompt": "^6.1.0"
|
|
81
74
|
}
|
|
82
75
|
}
|