@whitesev/utils 1.9.2 → 1.9.4

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.
@@ -1,6 +1,7 @@
1
- declare class UtilsDictionary<K extends PropertyKey, V extends any> {
2
- #private;
1
+ declare class UtilsDictionary<K, V> {
2
+ private items;
3
3
  constructor();
4
+ constructor(key: K, value: V);
4
5
  /**
5
6
  * 检查是否有某一个键
6
7
  * @param key 键
@@ -15,7 +16,7 @@ declare class UtilsDictionary<K extends PropertyKey, V extends any> {
15
16
  * 获取以xx开头的键的值
16
17
  * @param key 需要匹配的键
17
18
  */
18
- getStartsWith(key: K): V;
19
+ getStartsWith(key: K): V | undefined;
19
20
  /**
20
21
  * 为字典添加某一个值
21
22
  * @param key 键
@@ -29,13 +30,11 @@ declare class UtilsDictionary<K extends PropertyKey, V extends any> {
29
30
  delete(key: K): boolean;
30
31
  /**
31
32
  * 获取某个键的值
33
+ * https://github.com/microsoft/TypeScript/issues/9619
34
+ * 微软到现在都没有修复has和get的联动
32
35
  * @param key 键
33
36
  */
34
- get(key: K): {
35
- [key: string]: V;
36
- [key: number]: V;
37
- [key: symbol]: V;
38
- }[K] | undefined;
37
+ get(key: K): V;
39
38
  /**
40
39
  * 返回字典中的所有值
41
40
  */
@@ -51,15 +50,11 @@ declare class UtilsDictionary<K extends PropertyKey, V extends any> {
51
50
  /**
52
51
  * 获取字典所有的键
53
52
  */
54
- keys(): string[];
53
+ keys(): (string | symbol)[];
55
54
  /**
56
55
  * 返回字典本身
57
56
  */
58
- getItems(): {
59
- [key: string]: V;
60
- [key: number]: V;
61
- [key: symbol]: V;
62
- };
57
+ getItems(): UtilsDictionary<K, V>;
63
58
  /**
64
59
  * 合并另一个字典
65
60
  * @param data 需要合并的字典
@@ -1,16 +1,16 @@
1
1
  export declare interface UtilsCoreOption {
2
2
  document: Document;
3
- window: Window;
4
- globalThis: typeof globalThis;
5
- self: typeof globalThis;
6
- top: Window;
3
+ window: Window | typeof globalThis;
4
+ globalThis: Window | typeof globalThis;
5
+ self: Window | typeof globalThis;
6
+ top: Window | typeof globalThis;
7
7
  }
8
8
  declare const UtilsCore: {
9
9
  init(option?: UtilsCoreOption): void;
10
10
  readonly document: Document;
11
- readonly window: Window;
12
- readonly globalThis: typeof globalThis;
13
- readonly self: typeof globalThis;
14
- readonly top: Window;
11
+ readonly window: typeof globalThis | Window;
12
+ readonly globalThis: typeof globalThis | Window;
13
+ readonly self: typeof globalThis | Window;
14
+ readonly top: typeof globalThis | Window;
15
15
  };
16
16
  export { UtilsCore };
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "@whitesev/utils",
3
- "version": "1.9.2",
4
- "description": "一个常用的工具库",
5
- "main": "dist/index.cjs.js",
6
- "module": "dist/node/index.esm.js",
7
- "types": "dist/index.d.ts",
8
- "jsdelivr": "dist/index.umd.js",
9
- "exports": {
10
- "./package.json": "./package.json",
11
- ".": {
12
- "import": "./dist/index.esm.js",
13
- "require": "./dist/index.cjs.js",
14
- "types": "./dist/index.d.ts"
15
- }
16
- },
17
- "files": [
18
- "dist"
19
- ],
20
- "scripts": {
21
- "build": "rollup --config"
22
- },
23
- "publishConfig": {
24
- "registry": "https://registry.npmjs.org/"
25
- },
26
- "keywords": [
27
- "typescript",
28
- "Utils",
29
- "工具类",
30
- "TamperMonkey",
31
- "VioletMonkey",
32
- "ScriptCat"
33
- ],
34
- "author": "WhiteSev",
35
- "license": "MIT",
36
- "dependencies": {
37
- "@rollup/plugin-babel": "^6.0.4",
38
- "@rollup/plugin-commonjs": "^25.0.8",
39
- "@rollup/plugin-node-resolve": "^15.2.3",
40
- "@rollup/plugin-typescript": "^11.1.6",
41
- "rollup-plugin-clear": "^2.0.7",
42
- "tslib": "^2.6.2"
43
- },
44
- "devDependencies": {
45
- "typescript": "^5.4.5"
46
- }
47
- }
1
+ {
2
+ "name": "@whitesev/utils",
3
+ "version": "1.9.4",
4
+ "description": "一个常用的工具库",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/node/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "jsdelivr": "dist/index.umd.js",
9
+ "exports": {
10
+ "./package.json": "./package.json",
11
+ ".": {
12
+ "import": "./dist/index.esm.js",
13
+ "require": "./dist/index.cjs.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "publishConfig": {
21
+ "registry": "https://registry.npmjs.org/"
22
+ },
23
+ "keywords": [
24
+ "typescript",
25
+ "Utils",
26
+ "工具类",
27
+ "TamperMonkey",
28
+ "VioletMonkey",
29
+ "ScriptCat"
30
+ ],
31
+ "author": "WhiteSev",
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@rollup/plugin-babel": "^6.0.4",
35
+ "@rollup/plugin-commonjs": "^26.0.1",
36
+ "@rollup/plugin-node-resolve": "^15.2.3",
37
+ "@rollup/plugin-typescript": "^11.1.6",
38
+ "rollup-plugin-clear": "^2.0.7",
39
+ "tslib": "^2.6.3"
40
+ },
41
+ "devDependencies": {
42
+ "typescript": "^5.5.4"
43
+ },
44
+ "scripts": {
45
+ "build": "rollup --config"
46
+ }
47
+ }