Browse Source

declare global

Paul 5 years ago
parent
commit
4a13df0968
3 changed files with 13 additions and 3 deletions
  1. 5
    0
      dist/types/utils.d.ts
  2. 1
    1
      dist/utils.js.map
  3. 7
    2
      src/utils.ts

+ 5
- 0
dist/types/utils.d.ts View File

1
+declare global {
2
+    interface Window {
3
+        crcTable: number[];
4
+    }
5
+}
1
 declare class Utils {
6
 declare class Utils {
2
     private static code;
7
     private static code;
3
     static crc32(str: string): number;
8
     static crc32(str: string): number;

+ 1
- 1
dist/utils.js.map
File diff suppressed because it is too large
View File


+ 7
- 2
src/utils.ts View File

1
 import { AES, enc, mode, pad } from 'crypto-js';
1
 import { AES, enc, mode, pad } from 'crypto-js';
2
 
2
 
3
+declare global {
4
+  interface Window {
5
+    crcTable: number[];
6
+  }
7
+}
8
+
3
 class Utils {
9
 class Utils {
4
   private static code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(
10
   private static code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(
5
     '',
11
     '',
6
   );
12
   );
7
 
13
 
8
   public static crc32(str: string): number {
14
   public static crc32(str: string): number {
9
-    let crcTable =
10
-      (<any>window).crcTable || ((<any>window).crcTable = Utils.makeCRCTable());
15
+    let crcTable = window.crcTable || (window.crcTable = Utils.makeCRCTable());
11
     let crc = 0 ^ -1;
16
     let crc = 0 ^ -1;
12
 
17
 
13
     for (let i = 0; i < str.length; i++) {
18
     for (let i = 0; i < str.length; i++) {