@rg-dev/stdlib 1.0.10 → 1.0.12
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/lib/common-env.cjs +6 -6
- package/lib/common-env.d.cts +4 -4
- package/lib/common-env.d.ts +4 -4
- package/lib/common-env.js +6 -6
- package/package.json +1 -1
package/lib/common-env.cjs
CHANGED
|
@@ -61,18 +61,18 @@ function promiseRetry(func, options = defaultOptions, attempt = 1) {
|
|
|
61
61
|
|
|
62
62
|
// src/common-env.ts
|
|
63
63
|
var Optional = class _Optional {
|
|
64
|
+
value;
|
|
64
65
|
constructor(value) {
|
|
65
66
|
this.value = value;
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
+
static of(val) {
|
|
69
|
+
return new _Optional(val);
|
|
70
|
+
}
|
|
68
71
|
orElseThrow(msg) {
|
|
69
|
-
if (this.value
|
|
72
|
+
if (this.value === void 0)
|
|
70
73
|
throw new Error(msg || "Value is empty");
|
|
71
74
|
return this.value;
|
|
72
75
|
}
|
|
73
|
-
static of(val) {
|
|
74
|
-
return new _Optional(val);
|
|
75
|
-
}
|
|
76
76
|
setValue(newValue) {
|
|
77
77
|
this.value = newValue;
|
|
78
78
|
return this;
|
|
@@ -81,7 +81,7 @@ var Optional = class _Optional {
|
|
|
81
81
|
return this.value;
|
|
82
82
|
}
|
|
83
83
|
ifPresent(action) {
|
|
84
|
-
if (this.value
|
|
84
|
+
if (this.value === void 0)
|
|
85
85
|
return;
|
|
86
86
|
try {
|
|
87
87
|
action(this.value);
|
package/lib/common-env.d.cts
CHANGED
|
@@ -9,15 +9,15 @@ type MyFn<T extends Record<string, (...args: any[]) => any>> = {
|
|
|
9
9
|
[K in keyof T]: (...args: Parameters<T[K]>) => void;
|
|
10
10
|
};
|
|
11
11
|
type AsyncReturnType<T extends (...args: any) => any> = Awaited<ReturnType<T>>;
|
|
12
|
-
type MaybeFunction = (() => void) | undefined;
|
|
12
|
+
type MaybeFunction = ((...args: any) => void) | undefined;
|
|
13
13
|
declare class Optional<T> {
|
|
14
|
-
private constructor();
|
|
15
14
|
private value;
|
|
16
|
-
|
|
15
|
+
private constructor();
|
|
17
16
|
static of<T>(val: T): Optional<T>;
|
|
17
|
+
orElseThrow(msg?: string): T;
|
|
18
18
|
setValue(newValue: T): this;
|
|
19
19
|
getValue(): T | undefined;
|
|
20
|
-
ifPresent(action: (val: T) => void): void;
|
|
20
|
+
ifPresent(action: (val: Exclude<T, undefined>) => void): void;
|
|
21
21
|
}
|
|
22
22
|
declare function sleep(ms: number): Promise<unknown>;
|
|
23
23
|
declare function isNumber(num: any): boolean;
|
package/lib/common-env.d.ts
CHANGED
|
@@ -9,15 +9,15 @@ type MyFn<T extends Record<string, (...args: any[]) => any>> = {
|
|
|
9
9
|
[K in keyof T]: (...args: Parameters<T[K]>) => void;
|
|
10
10
|
};
|
|
11
11
|
type AsyncReturnType<T extends (...args: any) => any> = Awaited<ReturnType<T>>;
|
|
12
|
-
type MaybeFunction = (() => void) | undefined;
|
|
12
|
+
type MaybeFunction = ((...args: any) => void) | undefined;
|
|
13
13
|
declare class Optional<T> {
|
|
14
|
-
private constructor();
|
|
15
14
|
private value;
|
|
16
|
-
|
|
15
|
+
private constructor();
|
|
17
16
|
static of<T>(val: T): Optional<T>;
|
|
17
|
+
orElseThrow(msg?: string): T;
|
|
18
18
|
setValue(newValue: T): this;
|
|
19
19
|
getValue(): T | undefined;
|
|
20
|
-
ifPresent(action: (val: T) => void): void;
|
|
20
|
+
ifPresent(action: (val: Exclude<T, undefined>) => void): void;
|
|
21
21
|
}
|
|
22
22
|
declare function sleep(ms: number): Promise<unknown>;
|
|
23
23
|
declare function isNumber(num: any): boolean;
|
package/lib/common-env.js
CHANGED
|
@@ -28,18 +28,18 @@ function promiseRetry(func, options = defaultOptions, attempt = 1) {
|
|
|
28
28
|
|
|
29
29
|
// src/common-env.ts
|
|
30
30
|
var Optional = class _Optional {
|
|
31
|
+
value;
|
|
31
32
|
constructor(value) {
|
|
32
33
|
this.value = value;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
+
static of(val) {
|
|
36
|
+
return new _Optional(val);
|
|
37
|
+
}
|
|
35
38
|
orElseThrow(msg) {
|
|
36
|
-
if (this.value
|
|
39
|
+
if (this.value === void 0)
|
|
37
40
|
throw new Error(msg || "Value is empty");
|
|
38
41
|
return this.value;
|
|
39
42
|
}
|
|
40
|
-
static of(val) {
|
|
41
|
-
return new _Optional(val);
|
|
42
|
-
}
|
|
43
43
|
setValue(newValue) {
|
|
44
44
|
this.value = newValue;
|
|
45
45
|
return this;
|
|
@@ -48,7 +48,7 @@ var Optional = class _Optional {
|
|
|
48
48
|
return this.value;
|
|
49
49
|
}
|
|
50
50
|
ifPresent(action) {
|
|
51
|
-
if (this.value
|
|
51
|
+
if (this.value === void 0)
|
|
52
52
|
return;
|
|
53
53
|
try {
|
|
54
54
|
action(this.value);
|