Sfoglia il codice sorgente

Added missing types

sanex3339 8 anni fa
parent
commit
a8b3255970
1 ha cambiato i file con 9 aggiunte e 7 eliminazioni
  1. 9 7
      src/Utils.ts

+ 9 - 7
src/Utils.ts

@@ -112,11 +112,13 @@ export class Utils {
      * @returns {string[]}
      * @returns {string[]}
      */
      */
     public static hideString(str: string, length: number): [string, string] {
     public static hideString(str: string, length: number): [string, string] {
-        const escapeRegExp = (s: string) =>
+        const escapeRegExp: (s: string) => string = (s: string) =>
             s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
             s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
 
 
-        const randomMerge = function (s1: string, s2: string): string {
-            let i1 = -1, i2 = -1, result = '';
+        const randomMerge: (s1: string, s2: string) => string = function (s1: string, s2: string): string {
+            let i1: number = -1,
+                i2: number = -1,
+                result: string = '';
 
 
             while (i1 < s1.length || i2 < s2.length) {
             while (i1 < s1.length || i2 < s2.length) {
                 if (Math.random() < 0.5 && i2 < s2.length) {
                 if (Math.random() < 0.5 && i2 < s2.length) {
@@ -129,13 +131,13 @@ export class Utils {
             return result;
             return result;
         };
         };
 
 
-        const customPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+        const customPool: string = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
 
 
-        let randomString = Utils.randomGenerator.string({length: length, pool: customPool}),
-            randomStringDiff = randomString.replace(
+        let randomString: string = Utils.randomGenerator.string({length: length, pool: customPool}),
+            randomStringDiff: string = randomString.replace(
                 new RegExp('[' + escapeRegExp(str) + ']', 'g'),
                 new RegExp('[' + escapeRegExp(str) + ']', 'g'),
             ''),
             ''),
-            randomStringDiffArray = randomStringDiff.split('');
+            randomStringDiffArray: string[] = randomStringDiff.split('');
 
 
         Utils.randomGenerator.shuffle(randomStringDiffArray);
         Utils.randomGenerator.shuffle(randomStringDiffArray);
         randomStringDiff = randomStringDiffArray.join('');
         randomStringDiff = randomStringDiffArray.join('');