Jelajahi Sumber

Add comments to getWord / WordResult

Danilo Bargen 7 tahun lalu
induk
melakukan
22dde4b6c3
2 mengubah file dengan 12 tambahan dan 0 penghapusan
  1. 10 0
      src/services/string.ts
  2. 2 0
      src/threema.d.ts

+ 10 - 0
src/services/string.ts

@@ -59,6 +59,16 @@ export class StringService {
         return chunks;
     }
 
+    /**
+     * Return the word below the cursor position.
+     *
+     * If the cursor is at the end of a word, the word to the left of it will
+     * be returned.
+     *
+     * If there is whitespace to the left of the cursor, then the returned
+     * `WordResult` object will include the trimmed word to the left of the
+     * cursor. The `realLength` includes the trimmed whitespace though.
+     */
     public getWord(input: string, pos: number, additionalSeparators: string[] = null): threema.WordResult {
         const result = {
             word: null,

+ 2 - 0
src/threema.d.ts

@@ -496,7 +496,9 @@ declare namespace threema {
     }
 
     interface WordResult {
+        // The trimmed word
         word: string;
+        // The length of the untrimmed word
         realLength: number;
     }