@tutao/tutanota-utils 3.93.5 → 3.94.0
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/dist/ArrayUtils.d.ts +44 -39
- package/dist/ArrayUtils.js +220 -229
- package/dist/AsyncResult.d.ts +17 -15
- package/dist/AsyncResult.js +33 -21
- package/dist/CollectionUtils.d.ts +1 -1
- package/dist/CollectionUtils.js +1 -1
- package/dist/DateUtils.d.ts +18 -18
- package/dist/DateUtils.js +40 -38
- package/dist/Encoding.d.ts +25 -25
- package/dist/Encoding.js +175 -181
- package/dist/LazyLoaded.d.ts +32 -32
- package/dist/LazyLoaded.js +65 -66
- package/dist/MapUtils.d.ts +4 -4
- package/dist/MapUtils.js +24 -25
- package/dist/MathUtils.d.ts +2 -2
- package/dist/MathUtils.js +2 -2
- package/dist/PromiseMap.d.ts +8 -4
- package/dist/PromiseMap.js +49 -50
- package/dist/PromiseUtils.d.ts +19 -16
- package/dist/PromiseUtils.js +72 -76
- package/dist/SortedArray.d.ts +11 -11
- package/dist/SortedArray.js +30 -30
- package/dist/StringUtils.d.ts +14 -14
- package/dist/StringUtils.js +31 -36
- package/dist/TypeRef.d.ts +11 -10
- package/dist/TypeRef.js +15 -12
- package/dist/Utils.d.ts +59 -53
- package/dist/Utils.js +207 -227
- package/dist/index.d.ts +145 -19
- package/dist/index.js +140 -14
- package/dist/tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/SortedArray.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export declare type CompareFn<T> = (arg0: T, arg1: T) => number
|
|
1
|
+
export declare type CompareFn<T> = (arg0: T, arg1: T) => number
|
|
2
2
|
/**
|
|
3
3
|
* An array that keeps itself sorted
|
|
4
4
|
*/
|
|
5
5
|
export declare class SortedArray<T> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
readonly _contents: Array<T>
|
|
7
|
+
readonly _compareFn: CompareFn<T>
|
|
8
|
+
constructor(compareFn?: CompareFn<T>)
|
|
9
|
+
static from<U>(array: ReadonlyArray<U>, compareFn?: CompareFn<U>): SortedArray<U>
|
|
10
|
+
get length(): number
|
|
11
|
+
get array(): ReadonlyArray<T>
|
|
12
|
+
get(index: number): T
|
|
13
|
+
insertAll(array: ReadonlyArray<T>): void
|
|
14
|
+
insert(item: T): void
|
|
15
|
+
removeFirst(finder: (arg0: T) => boolean): boolean
|
|
16
16
|
}
|
package/dist/SortedArray.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findAndRemove, insertIntoSortedArray } from "./ArrayUtils.js"
|
|
1
|
+
import { findAndRemove, insertIntoSortedArray } from "./ArrayUtils.js"
|
|
2
2
|
/**
|
|
3
3
|
* Compared based on the type's natural ordering
|
|
4
4
|
* @param a
|
|
@@ -7,38 +7,38 @@ import { findAndRemove, insertIntoSortedArray } from "./ArrayUtils.js";
|
|
|
7
7
|
*/
|
|
8
8
|
// It should be fine for 99% of use cases? worst case it just returns 0 always
|
|
9
9
|
function defaultCompare(a, b) {
|
|
10
|
-
|
|
10
|
+
return a < b ? -1 : a > b ? 1 : 0
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* An array that keeps itself sorted
|
|
14
14
|
*/
|
|
15
15
|
export class SortedArray {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
constructor(compareFn = defaultCompare) {
|
|
17
|
+
this._contents = []
|
|
18
|
+
this._compareFn = compareFn
|
|
19
|
+
}
|
|
20
|
+
static from(array, compareFn) {
|
|
21
|
+
const list = new SortedArray(compareFn)
|
|
22
|
+
list.insertAll(array)
|
|
23
|
+
return list
|
|
24
|
+
}
|
|
25
|
+
get length() {
|
|
26
|
+
return this._contents.length
|
|
27
|
+
}
|
|
28
|
+
get array() {
|
|
29
|
+
return this._contents
|
|
30
|
+
}
|
|
31
|
+
get(index) {
|
|
32
|
+
return this._contents[index]
|
|
33
|
+
}
|
|
34
|
+
insertAll(array) {
|
|
35
|
+
this._contents.push(...array)
|
|
36
|
+
this._contents.sort(this._compareFn)
|
|
37
|
+
}
|
|
38
|
+
insert(item) {
|
|
39
|
+
insertIntoSortedArray(item, this._contents, this._compareFn)
|
|
40
|
+
}
|
|
41
|
+
removeFirst(finder) {
|
|
42
|
+
return findAndRemove(this._contents, finder)
|
|
43
|
+
}
|
|
44
44
|
}
|
package/dist/StringUtils.d.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import type { lazy } from "./Utils.js"
|
|
1
|
+
import type { lazy } from "./Utils.js"
|
|
2
2
|
/**
|
|
3
3
|
* Returns a string which contains the given number padded with 0s.
|
|
4
4
|
* @param num The number to pad.
|
|
5
5
|
* @param size The number of resulting digits.
|
|
6
6
|
* @return The padded number as string.
|
|
7
7
|
*/
|
|
8
|
-
export declare function pad(num: number, size: number): string
|
|
8
|
+
export declare function pad(num: number, size: number): string
|
|
9
9
|
/**
|
|
10
10
|
* Checks if a string starts with another string.
|
|
11
11
|
* @param string The string to test.
|
|
12
12
|
* @param substring If the other string begins with this one, we return true.
|
|
13
13
|
* @return True if string begins with substring, false otherwise.
|
|
14
14
|
*/
|
|
15
|
-
export declare function startsWith(string: string, substring: string): boolean
|
|
15
|
+
export declare function startsWith(string: string, substring: string): boolean
|
|
16
16
|
/**
|
|
17
17
|
* uppercase the first letter of a string, lowercase the rest
|
|
18
18
|
* @param str string to transform
|
|
19
19
|
* @returns {string} str in lowercase with first letter Capitalized
|
|
20
20
|
*/
|
|
21
|
-
export declare function capitalizeFirstLetter(str: string): string
|
|
21
|
+
export declare function capitalizeFirstLetter(str: string): string
|
|
22
22
|
/**
|
|
23
23
|
* Checks if a string ends with another string.
|
|
24
24
|
* @param string The string to test.
|
|
25
25
|
* @param substring If the other string ends with this one, we return true.
|
|
26
26
|
* @return True if string ends with substring, false otherwise.
|
|
27
27
|
*/
|
|
28
|
-
export declare function endsWith(string: string, substring: string): boolean
|
|
29
|
-
export declare function lazyStringValue(valueOrLazy: string | lazy<string>): string
|
|
30
|
-
export declare function repeat(value: string, length: number): string
|
|
31
|
-
export declare function cleanMatch(s1: string, s2: string): boolean
|
|
28
|
+
export declare function endsWith(string: string, substring: string): boolean
|
|
29
|
+
export declare function lazyStringValue(valueOrLazy: string | lazy<string>): string
|
|
30
|
+
export declare function repeat(value: string, length: number): string
|
|
31
|
+
export declare function cleanMatch(s1: string, s2: string): boolean
|
|
32
32
|
/**
|
|
33
33
|
* Non-breaking space character
|
|
34
34
|
*/
|
|
35
|
-
export declare const NBSP = "\u00A0"
|
|
35
|
+
export declare const NBSP = "\u00A0"
|
|
36
36
|
/**
|
|
37
37
|
* split a string at a given index
|
|
38
38
|
* @param str
|
|
39
39
|
* @param index
|
|
40
40
|
*/
|
|
41
|
-
export declare function splitAt(str: string, index: number): [string, string]
|
|
41
|
+
export declare function splitAt(str: string, index: number): [string, string]
|
|
42
42
|
/**
|
|
43
43
|
* Wrapper around String.prototype.toLowerCase, nice for calls to Array.prototype.map
|
|
44
44
|
* @param str
|
|
45
45
|
*/
|
|
46
|
-
export declare function toLowerCase(str: string): string
|
|
46
|
+
export declare function toLowerCase(str: string): string
|
|
47
47
|
/**
|
|
48
48
|
* Wrapper around String.prototype.localeCompare, for passing to Array.prototype.sort
|
|
49
49
|
* @param a
|
|
50
50
|
* @param b
|
|
51
51
|
* @returns {number}
|
|
52
52
|
*/
|
|
53
|
-
export declare function localeCompare(a: string, b: string): number
|
|
54
|
-
export declare function byteLength(str: string | null | undefined): number
|
|
53
|
+
export declare function localeCompare(a: string, b: string): number
|
|
54
|
+
export declare function byteLength(str: string | null | undefined): number
|
|
55
55
|
/**
|
|
56
56
|
* replace all instances of substr in str with replacement
|
|
57
57
|
*/
|
|
58
|
-
export declare function replaceAll(str: string, substr: string, replacement: string): string
|
|
58
|
+
export declare function replaceAll(str: string, substr: string, replacement: string): string
|
package/dist/StringUtils.js
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* @return The padded number as string.
|
|
6
6
|
*/
|
|
7
7
|
export function pad(num, size) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return s;
|
|
8
|
+
var s = num + ""
|
|
9
|
+
while (s.length < size) s = "0" + s
|
|
10
|
+
return s
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
13
|
* Checks if a string starts with another string.
|
|
@@ -17,7 +16,7 @@ export function pad(num, size) {
|
|
|
17
16
|
* @return True if string begins with substring, false otherwise.
|
|
18
17
|
*/
|
|
19
18
|
export function startsWith(string, substring) {
|
|
20
|
-
|
|
19
|
+
return string.startsWith(substring)
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
22
|
* uppercase the first letter of a string, lowercase the rest
|
|
@@ -25,7 +24,7 @@ export function startsWith(string, substring) {
|
|
|
25
24
|
* @returns {string} str in lowercase with first letter Capitalized
|
|
26
25
|
*/
|
|
27
26
|
export function capitalizeFirstLetter(str) {
|
|
28
|
-
|
|
27
|
+
return str[0].toUpperCase() + str.toLowerCase().slice(1)
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Checks if a string ends with another string.
|
|
@@ -34,39 +33,39 @@ export function capitalizeFirstLetter(str) {
|
|
|
34
33
|
* @return True if string ends with substring, false otherwise.
|
|
35
34
|
*/
|
|
36
35
|
export function endsWith(string, substring) {
|
|
37
|
-
|
|
36
|
+
return string.endsWith(substring)
|
|
38
37
|
}
|
|
39
38
|
export function lazyStringValue(valueOrLazy) {
|
|
40
|
-
|
|
39
|
+
return typeof valueOrLazy === "function" ? valueOrLazy() : valueOrLazy
|
|
41
40
|
}
|
|
42
41
|
export function repeat(value, length) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
let result = ""
|
|
43
|
+
for (let i = 0; i < length; i++) {
|
|
44
|
+
result += value
|
|
45
|
+
}
|
|
46
|
+
return result
|
|
48
47
|
}
|
|
49
48
|
export function cleanMatch(s1, s2) {
|
|
50
|
-
|
|
49
|
+
return s1.toLowerCase().trim() === s2.toLowerCase().trim()
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
52
|
* Non-breaking space character
|
|
54
53
|
*/
|
|
55
|
-
export const NBSP = "\u00A0"
|
|
54
|
+
export const NBSP = "\u00A0"
|
|
56
55
|
/**
|
|
57
56
|
* split a string at a given index
|
|
58
57
|
* @param str
|
|
59
58
|
* @param index
|
|
60
59
|
*/
|
|
61
60
|
export function splitAt(str, index) {
|
|
62
|
-
|
|
61
|
+
return [str.substring(0, index), str.substring(index)]
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
64
|
* Wrapper around String.prototype.toLowerCase, nice for calls to Array.prototype.map
|
|
66
65
|
* @param str
|
|
67
66
|
*/
|
|
68
67
|
export function toLowerCase(str) {
|
|
69
|
-
|
|
68
|
+
return str.toLowerCase()
|
|
70
69
|
}
|
|
71
70
|
/**
|
|
72
71
|
* Wrapper around String.prototype.localeCompare, for passing to Array.prototype.sort
|
|
@@ -75,36 +74,32 @@ export function toLowerCase(str) {
|
|
|
75
74
|
* @returns {number}
|
|
76
75
|
*/
|
|
77
76
|
export function localeCompare(a, b) {
|
|
78
|
-
|
|
77
|
+
return a.localeCompare(b)
|
|
79
78
|
}
|
|
80
79
|
export function byteLength(str) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (code >= 0xdc00 && code <= 0xdfff)
|
|
93
|
-
i--; //trail surrogate
|
|
94
|
-
}
|
|
95
|
-
return s;
|
|
80
|
+
if (str == null) return 0
|
|
81
|
+
// returns the byte length of an utf8 string
|
|
82
|
+
var s = str.length
|
|
83
|
+
for (var i = str.length - 1; i >= 0; i--) {
|
|
84
|
+
var code = str.charCodeAt(i)
|
|
85
|
+
if (code > 0x7f && code <= 0x7ff) {
|
|
86
|
+
s++
|
|
87
|
+
} else if (code > 0x7ff && code <= 0xffff) s += 2
|
|
88
|
+
if (code >= 0xdc00 && code <= 0xdfff) i-- //trail surrogate
|
|
89
|
+
}
|
|
90
|
+
return s
|
|
96
91
|
}
|
|
97
92
|
/**
|
|
98
93
|
* replace all instances of substr in str with replacement
|
|
99
94
|
*/
|
|
100
95
|
export function replaceAll(str, substr, replacement) {
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
const regex = escapedStringRegExp(substr, "g")
|
|
97
|
+
return str.replace(regex, replacement)
|
|
103
98
|
}
|
|
104
99
|
/**
|
|
105
100
|
* Create a regex to exactly match a given string, by escaping any special regex characters
|
|
106
101
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
|
|
107
102
|
* */
|
|
108
103
|
function escapedStringRegExp(str, flags) {
|
|
109
|
-
|
|
104
|
+
return new RegExp(str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), flags)
|
|
110
105
|
}
|
package/dist/TypeRef.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export declare class TypeRef<T> {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
readonly app: string
|
|
3
|
+
readonly type: string
|
|
4
|
+
/**
|
|
5
|
+
* Field that is never set. Used to make two TypeRefs incompatible (they are structurally compared otherwise).
|
|
6
|
+
* Cannot be private.
|
|
7
|
+
*/
|
|
8
|
+
readonly phantom: T | null
|
|
9
|
+
constructor(app: string, type: string)
|
|
10
|
+
toString(): string
|
|
10
11
|
}
|
|
11
|
-
export declare function isSameTypeRefByAttr(typeRef: TypeRef<any>, app: string, type: string): boolean
|
|
12
|
-
export declare function isSameTypeRef(typeRef1: TypeRef<any>, typeRef2: TypeRef<any>): boolean
|
|
12
|
+
export declare function isSameTypeRefByAttr(typeRef: TypeRef<any>, app: string, type: string): boolean
|
|
13
|
+
export declare function isSameTypeRef(typeRef1: TypeRef<any>, typeRef2: TypeRef<any>): boolean
|
package/dist/TypeRef.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
// T should be restricted to Entity
|
|
2
2
|
export class TypeRef {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
constructor(app, type) {
|
|
4
|
+
/**
|
|
5
|
+
* Field that is never set. Used to make two TypeRefs incompatible (they are structurally compared otherwise).
|
|
6
|
+
* Cannot be private.
|
|
7
|
+
*/
|
|
8
|
+
this.phantom = null
|
|
9
|
+
this.app = app
|
|
10
|
+
this.type = type
|
|
11
|
+
Object.freeze(this)
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return `[TypeRef ${this.app} ${this.type}]`
|
|
15
|
+
}
|
|
13
16
|
}
|
|
14
17
|
export function isSameTypeRefByAttr(typeRef, app, type) {
|
|
15
|
-
|
|
18
|
+
return typeRef.app === app && typeRef.type === type
|
|
16
19
|
}
|
|
17
20
|
export function isSameTypeRef(typeRef1, typeRef2) {
|
|
18
|
-
|
|
21
|
+
return isSameTypeRefByAttr(typeRef1, typeRef2.app, typeRef2.type)
|
|
19
22
|
}
|
package/dist/Utils.d.ts
CHANGED
|
@@ -1,57 +1,63 @@
|
|
|
1
|
-
export declare type lazy<T> = () => T
|
|
2
|
-
export declare type lazyAsync<T> = () => Promise<T
|
|
3
|
-
export declare type Thunk = () => unknown
|
|
1
|
+
export declare type lazy<T> = () => T
|
|
2
|
+
export declare type lazyAsync<T> = () => Promise<T>
|
|
3
|
+
export declare type Thunk = () => unknown
|
|
4
4
|
export declare type DeferredObject<T> = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
5
|
+
resolve: (arg0: T) => void
|
|
6
|
+
reject: (arg0: Error) => void
|
|
7
|
+
promise: Promise<T>
|
|
8
|
+
}
|
|
9
9
|
export declare type DeferredObjectWithHandler<T, U> = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
export declare function defer<T>(): DeferredObject<T
|
|
15
|
-
export declare function deferWithHandler<T, U>(handler: (arg0: T) => U): DeferredObjectWithHandler<T, U
|
|
16
|
-
export declare function asyncFind<T>(
|
|
17
|
-
|
|
10
|
+
resolve: (arg0: T) => void
|
|
11
|
+
reject: (arg0: Error) => void
|
|
12
|
+
promise: Promise<U>
|
|
13
|
+
}
|
|
14
|
+
export declare function defer<T>(): DeferredObject<T>
|
|
15
|
+
export declare function deferWithHandler<T, U>(handler: (arg0: T) => U): DeferredObjectWithHandler<T, U>
|
|
16
|
+
export declare function asyncFind<T>(
|
|
17
|
+
array: ReadonlyArray<T>,
|
|
18
|
+
finder: (item: T, index: number, arrayLength: number) => Promise<boolean>,
|
|
19
|
+
): Promise<T | null | undefined>
|
|
20
|
+
export declare function asyncFindAndMap<T, R>(
|
|
21
|
+
array: ReadonlyArray<T>,
|
|
22
|
+
finder: (item: T, index: number, arrayLength: number) => Promise<R | null>,
|
|
23
|
+
): Promise<R | null | undefined>
|
|
18
24
|
/**
|
|
19
25
|
* Calls an executor function for slices of nbrOfElementsInGroup items of the given array until the executor function returns false.
|
|
20
26
|
*/
|
|
21
|
-
export declare function executeInGroups<T>(array: T[], nbrOfElementsInGroup: number, executor: (items: T[]) => Promise<boolean>): Promise<void
|
|
22
|
-
export declare function neverNull<T>(object: T): NonNullable<T
|
|
23
|
-
export declare function assertNotNull<T>(object: T | null | undefined, message?: string): T
|
|
24
|
-
export declare function isNotNull<T>(t: T | null | undefined): t is T
|
|
25
|
-
export declare function assert(assertion: MaybeLazy<boolean>, message: string): void
|
|
26
|
-
export declare function downcast<R = any>(object: any): R
|
|
27
|
-
export declare function clone<T>(instance: T): T
|
|
27
|
+
export declare function executeInGroups<T>(array: T[], nbrOfElementsInGroup: number, executor: (items: T[]) => Promise<boolean>): Promise<void>
|
|
28
|
+
export declare function neverNull<T>(object: T): NonNullable<T>
|
|
29
|
+
export declare function assertNotNull<T>(object: T | null | undefined, message?: string): T
|
|
30
|
+
export declare function isNotNull<T>(t: T | null | undefined): t is T
|
|
31
|
+
export declare function assert(assertion: MaybeLazy<boolean>, message: string): void
|
|
32
|
+
export declare function downcast<R = any>(object: any): R
|
|
33
|
+
export declare function clone<T>(instance: T): T
|
|
28
34
|
/**
|
|
29
35
|
* Function which accepts another function. On first invocation
|
|
30
36
|
* of this resulting function result will be remembered and returned
|
|
31
37
|
* on consequent invocations.
|
|
32
38
|
*/
|
|
33
|
-
export declare function lazyMemoized<T>(source: () => T): () => T
|
|
39
|
+
export declare function lazyMemoized<T>(source: () => T): () => T
|
|
34
40
|
/**
|
|
35
41
|
* Returns a cached version of {@param fn}.
|
|
36
42
|
* Cached function checks that argument is the same (with ===) and if it is then it returns the cached result.
|
|
37
43
|
* If the cached argument has changed then {@param fn} will be called with new argument and result will be cached again.
|
|
38
44
|
* Only remembers the last argument.
|
|
39
45
|
*/
|
|
40
|
-
export declare function memoized<T, R>(fn: (arg0: T) => R): (arg0: T) => R
|
|
46
|
+
export declare function memoized<T, R>(fn: (arg0: T) => R): (arg0: T) => R
|
|
41
47
|
/**
|
|
42
48
|
* Function which returns what was passed into it
|
|
43
49
|
*/
|
|
44
|
-
export declare function identity<T>(t: T): T
|
|
50
|
+
export declare function identity<T>(t: T): T
|
|
45
51
|
/**
|
|
46
52
|
* Function which does nothing.
|
|
47
53
|
*/
|
|
48
|
-
export declare function noOp(): void
|
|
54
|
+
export declare function noOp(): void
|
|
49
55
|
/**
|
|
50
56
|
* Return a function, which executed {@param toThrottle} only after it is not invoked for {@param timeout} ms.
|
|
51
57
|
* Executes function with the last passed arguments
|
|
52
58
|
* @return {Function}
|
|
53
59
|
*/
|
|
54
|
-
export declare function debounce<F extends (...args: any) => void>(timeout: number, toThrottle: F): F
|
|
60
|
+
export declare function debounce<F extends (...args: any) => void>(timeout: number, toThrottle: F): F
|
|
55
61
|
/**
|
|
56
62
|
* Returns a debounced function. When invoked for the first time, will just invoke
|
|
57
63
|
* {@param toThrottle}. On subsequent invocations it will either invoke it right away
|
|
@@ -59,67 +65,67 @@ export declare function debounce<F extends (...args: any) => void>(timeout: numb
|
|
|
59
65
|
* So the first and the last invocations in a series of invocations always take place
|
|
60
66
|
* but ones in the middle (which happen too often) are discarded.}
|
|
61
67
|
*/
|
|
62
|
-
export declare function debounceStart<F extends (...args: any) => void>(timeout: number, toThrottle: F): F
|
|
63
|
-
export declare function randomIntFromInterval(min: number, max: number): number
|
|
64
|
-
export declare function errorToString(error: Error): string
|
|
68
|
+
export declare function debounceStart<F extends (...args: any) => void>(timeout: number, toThrottle: F): F
|
|
69
|
+
export declare function randomIntFromInterval(min: number, max: number): number
|
|
70
|
+
export declare function errorToString(error: Error): string
|
|
65
71
|
/**
|
|
66
72
|
* Like {@link Object.entries} but preserves the type of the key and value
|
|
67
73
|
*/
|
|
68
|
-
export declare function objectEntries<A extends string | symbol, B>(object: Record<A, B>): Array<[A, B]
|
|
74
|
+
export declare function objectEntries<A extends string | symbol, B>(object: Record<A, B>): Array<[A, B]>
|
|
69
75
|
/**
|
|
70
76
|
* modified deepEquals from ospec is only needed as long as we use custom classes (TypeRef) and Date is not properly handled
|
|
71
77
|
*/
|
|
72
|
-
export declare function deepEqual(a: any, b: any): boolean
|
|
78
|
+
export declare function deepEqual(a: any, b: any): boolean
|
|
73
79
|
/**
|
|
74
80
|
* returns an array of top-level properties that are in both objA and objB, but differ in value
|
|
75
81
|
* does not handle functions or circular references
|
|
76
82
|
* treats undefined and null as equal
|
|
77
83
|
*/
|
|
78
|
-
export declare function getChangedProps(objA: any, objB: any): Array<string
|
|
84
|
+
export declare function getChangedProps(objA: any, objB: any): Array<string>
|
|
79
85
|
/**
|
|
80
86
|
* Disallow set, delete and clear on Map.
|
|
81
87
|
* Important: It is *not* a deep freeze.
|
|
82
88
|
* @param myMap
|
|
83
89
|
* @return {unknown}
|
|
84
90
|
*/
|
|
85
|
-
export declare function freezeMap<K, V>(myMap: Map<K, V>): Map<K, V
|
|
86
|
-
export declare function addressDomain(senderAddress: string): string
|
|
91
|
+
export declare function freezeMap<K, V>(myMap: Map<K, V>): Map<K, V>
|
|
92
|
+
export declare function addressDomain(senderAddress: string): string
|
|
87
93
|
/**
|
|
88
94
|
* Ignores the fact that Object.keys returns also not owned properties.
|
|
89
95
|
*/
|
|
90
|
-
export declare function typedKeys<K extends string, V>(obj: Record<K, V>): Array<K
|
|
96
|
+
export declare function typedKeys<K extends string, V>(obj: Record<K, V>): Array<K>
|
|
91
97
|
/**
|
|
92
98
|
* Ignores the fact that Object.keys returns also not owned properties.
|
|
93
99
|
*/
|
|
94
|
-
export declare function typedEntries<K extends string, V>(obj: Record<K, V>): Array<[K, V]
|
|
100
|
+
export declare function typedEntries<K extends string, V>(obj: Record<K, V>): Array<[K, V]>
|
|
95
101
|
/**
|
|
96
102
|
* Ignores the fact that Object.keys returns also not owned properties.
|
|
97
103
|
*/
|
|
98
|
-
export declare function typedValues<K extends string, V>(obj: Record<K, V>): Array<V
|
|
99
|
-
export declare type MaybeLazy<T> = T | lazy<T
|
|
100
|
-
export declare function resolveMaybeLazy<T>(maybe: MaybeLazy<T>): T
|
|
101
|
-
export declare function getAsLazy<T>(maybe: MaybeLazy<T>): lazy<T
|
|
102
|
-
export declare function mapLazily<T, U>(maybe: MaybeLazy<T>, mapping: (arg0: T) => U): lazy<U
|
|
104
|
+
export declare function typedValues<K extends string, V>(obj: Record<K, V>): Array<V>
|
|
105
|
+
export declare type MaybeLazy<T> = T | lazy<T>
|
|
106
|
+
export declare function resolveMaybeLazy<T>(maybe: MaybeLazy<T>): T
|
|
107
|
+
export declare function getAsLazy<T>(maybe: MaybeLazy<T>): lazy<T>
|
|
108
|
+
export declare function mapLazily<T, U>(maybe: MaybeLazy<T>, mapping: (arg0: T) => U): lazy<U>
|
|
103
109
|
/**
|
|
104
110
|
* Stricter version of parseInt() from MDN. parseInt() allows some arbitrary characters at the end of the string.
|
|
105
111
|
* Returns NaN in case there's anything non-number in the string.
|
|
106
112
|
*/
|
|
107
|
-
export declare function filterInt(value: string): number
|
|
113
|
+
export declare function filterInt(value: string): number
|
|
108
114
|
interface Positioned {
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
x: number
|
|
116
|
+
y: number
|
|
111
117
|
}
|
|
112
118
|
interface Sized {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
top: number
|
|
120
|
+
left: number
|
|
121
|
+
bottom: number
|
|
122
|
+
right: number
|
|
117
123
|
}
|
|
118
|
-
export declare function insideRect(point: Positioned, rect: Sized): boolean
|
|
124
|
+
export declare function insideRect(point: Positioned, rect: Sized): boolean
|
|
119
125
|
/**
|
|
120
126
|
* If val is non null, returns the result of val passed to action, else null
|
|
121
127
|
*/
|
|
122
|
-
export declare function mapNullable<T, U>(val: T | null | undefined, action: (arg0: T) => U | null | undefined): U | null
|
|
128
|
+
export declare function mapNullable<T, U>(val: T | null | undefined, action: (arg0: T) => U | null | undefined): U | null
|
|
123
129
|
/** Helper to take instead of `typeof setTimeout` which is hellish to reproduce */
|
|
124
|
-
export declare type TimeoutSetter = (fn: () => unknown, arg1: number) => ReturnType<typeof setTimeout
|
|
125
|
-
export {}
|
|
130
|
+
export declare type TimeoutSetter = (fn: () => unknown, arg1: number) => ReturnType<typeof setTimeout>
|
|
131
|
+
export {}
|