@configura/web-utilities 2.1.0-alpha.2 → 2.1.0-alpha.3
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/.eslintrc.json +5 -5
- package/.gitattributes +3 -3
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/__tests__/cmMips.test.ts +129 -129
- package/__tests__/convertLength.test.ts +37 -37
- package/__tests__/price.test.ts +21 -21
- package/dist/GenericCache.d.ts +14 -14
- package/dist/GenericCache.js +38 -38
- package/dist/Observable/AccumulatingObservable.d.ts +10 -10
- package/dist/Observable/AccumulatingObservable.js +25 -25
- package/dist/Observable/AggregatedLoadingObservable.d.ts +10 -10
- package/dist/Observable/AggregatedLoadingObservable.js +28 -28
- package/dist/Observable/LogObservable.d.ts +42 -42
- package/dist/Observable/LogObservable.js +104 -104
- package/dist/Observable/LogProducer.d.ts +5 -5
- package/dist/Observable/LogProducer.js +9 -9
- package/dist/Observable/Observable.d.ts +12 -12
- package/dist/Observable/Observable.js +33 -33
- package/dist/PromiseCache.d.ts +4 -4
- package/dist/PromiseCache.js +28 -28
- package/dist/assert.d.ts +12 -12
- package/dist/assert.js +20 -20
- package/dist/cmMips.d.ts +26 -26
- package/dist/cmMips.js +159 -159
- package/dist/compare.d.ts +6 -6
- package/dist/compare.js +29 -29
- package/dist/error.d.ts +7 -7
- package/dist/error.js +24 -24
- package/dist/event.d.ts +2 -2
- package/dist/event.js +1 -1
- package/dist/filter.d.ts +22 -22
- package/dist/filter.js +19 -19
- package/dist/index.d.ts +21 -21
- package/dist/index.js +21 -21
- package/dist/utilitiesArray.d.ts +4 -4
- package/dist/utilitiesArray.js +49 -49
- package/dist/utilitiesFile.d.ts +6 -6
- package/dist/utilitiesFile.js +33 -33
- package/dist/utilitiesImage.d.ts +1 -1
- package/dist/utilitiesImage.js +19 -19
- package/dist/utilitiesMath.d.ts +3 -3
- package/dist/utilitiesMath.js +9 -9
- package/dist/utilitiesPrice.d.ts +1 -1
- package/dist/utilitiesPrice.js +16 -16
- package/dist/utilitiesPromise.d.ts +1 -1
- package/dist/utilitiesPromise.js +12 -12
- package/dist/utilitiesString.d.ts +1 -1
- package/dist/utilitiesString.js +12 -12
- package/dist/utilitiesUnits.d.ts +16 -16
- package/dist/utilitiesUnits.js +72 -72
- package/dist/utilitiesWeb.d.ts +3 -3
- package/dist/utilitiesWeb.js +20 -20
- package/package.json +2 -2
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { AccumulatingObservable } from "./AccumulatingObservable.js";
|
|
2
|
-
export declare enum LogLevel {
|
|
3
|
-
Log = "Log",
|
|
4
|
-
Info = "Info",
|
|
5
|
-
Warn = "Warn",
|
|
6
|
-
Error = "Error"
|
|
7
|
-
}
|
|
8
|
-
export declare class LogMessage {
|
|
9
|
-
level: LogLevel;
|
|
10
|
-
message: unknown;
|
|
11
|
-
optionalParams: unknown[];
|
|
12
|
-
constructor(level: LogLevel, message: unknown, optionalParams?: unknown[]);
|
|
13
|
-
get key(): string;
|
|
14
|
-
get levelMessageHash(): number;
|
|
15
|
-
equals(other: LogMessage): boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface Logger {
|
|
18
|
-
addPrebaked(logMessage: LogMessage, toConsoleLog?: boolean): void;
|
|
19
|
-
info(message: unknown, ...optionalParams: unknown[]): void;
|
|
20
|
-
warn(message: unknown, ...optionalParams: unknown[]): void;
|
|
21
|
-
warnFromCaught(error: unknown): void;
|
|
22
|
-
error(message: unknown, ...optionalParams: unknown[]): void;
|
|
23
|
-
errorFromCaught(error: unknown): void;
|
|
24
|
-
errorAsObject(message: unknown, ...optionalParams: unknown[]): Error;
|
|
25
|
-
}
|
|
26
|
-
export declare class LogObservable extends AccumulatingObservable<LogMessage> implements Logger {
|
|
27
|
-
private static _allObservables;
|
|
28
|
-
private static _accumulate;
|
|
29
|
-
static get accumulate(): boolean;
|
|
30
|
-
static set accumulate(v: boolean);
|
|
31
|
-
static get allMessages(): LogMessage[];
|
|
32
|
-
static clear(): void;
|
|
33
|
-
constructor();
|
|
34
|
-
addPrebaked: (m: LogMessage, toConsoleLog?: boolean) => void;
|
|
35
|
-
private someLog;
|
|
36
|
-
info(message: unknown, ...optionalParams: unknown[]): void;
|
|
37
|
-
warn(message: unknown, ...optionalParams: unknown[]): void;
|
|
38
|
-
warnFromCaught(e: unknown): void;
|
|
39
|
-
error(message: unknown, ...optionalParams: unknown[]): void;
|
|
40
|
-
errorFromCaught(e: unknown): void;
|
|
41
|
-
errorAsObject(message: unknown, ...optionalParams: unknown[]): Error;
|
|
42
|
-
}
|
|
1
|
+
import { AccumulatingObservable } from "./AccumulatingObservable.js";
|
|
2
|
+
export declare enum LogLevel {
|
|
3
|
+
Log = "Log",
|
|
4
|
+
Info = "Info",
|
|
5
|
+
Warn = "Warn",
|
|
6
|
+
Error = "Error"
|
|
7
|
+
}
|
|
8
|
+
export declare class LogMessage {
|
|
9
|
+
level: LogLevel;
|
|
10
|
+
message: unknown;
|
|
11
|
+
optionalParams: unknown[];
|
|
12
|
+
constructor(level: LogLevel, message: unknown, optionalParams?: unknown[]);
|
|
13
|
+
get key(): string;
|
|
14
|
+
get levelMessageHash(): number;
|
|
15
|
+
equals(other: LogMessage): boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface Logger {
|
|
18
|
+
addPrebaked(logMessage: LogMessage, toConsoleLog?: boolean): void;
|
|
19
|
+
info(message: unknown, ...optionalParams: unknown[]): void;
|
|
20
|
+
warn(message: unknown, ...optionalParams: unknown[]): void;
|
|
21
|
+
warnFromCaught(error: unknown): void;
|
|
22
|
+
error(message: unknown, ...optionalParams: unknown[]): void;
|
|
23
|
+
errorFromCaught(error: unknown): void;
|
|
24
|
+
errorAsObject(message: unknown, ...optionalParams: unknown[]): Error;
|
|
25
|
+
}
|
|
26
|
+
export declare class LogObservable extends AccumulatingObservable<LogMessage> implements Logger {
|
|
27
|
+
private static _allObservables;
|
|
28
|
+
private static _accumulate;
|
|
29
|
+
static get accumulate(): boolean;
|
|
30
|
+
static set accumulate(v: boolean);
|
|
31
|
+
static get allMessages(): LogMessage[];
|
|
32
|
+
static clear(): void;
|
|
33
|
+
constructor();
|
|
34
|
+
addPrebaked: (m: LogMessage, toConsoleLog?: boolean) => void;
|
|
35
|
+
private someLog;
|
|
36
|
+
info(message: unknown, ...optionalParams: unknown[]): void;
|
|
37
|
+
warn(message: unknown, ...optionalParams: unknown[]): void;
|
|
38
|
+
warnFromCaught(e: unknown): void;
|
|
39
|
+
error(message: unknown, ...optionalParams: unknown[]): void;
|
|
40
|
+
errorFromCaught(e: unknown): void;
|
|
41
|
+
errorAsObject(message: unknown, ...optionalParams: unknown[]): Error;
|
|
42
|
+
}
|
|
43
43
|
//# sourceMappingURL=LogObservable.d.ts.map
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { hashCode } from "../index.js";
|
|
2
|
-
import { AccumulatingObservable } from "./AccumulatingObservable.js";
|
|
3
|
-
export var LogLevel;
|
|
4
|
-
(function (LogLevel) {
|
|
5
|
-
LogLevel["Log"] = "Log";
|
|
6
|
-
LogLevel["Info"] = "Info";
|
|
7
|
-
LogLevel["Warn"] = "Warn";
|
|
8
|
-
LogLevel["Error"] = "Error";
|
|
9
|
-
})(LogLevel || (LogLevel = {}));
|
|
10
|
-
export class LogMessage {
|
|
11
|
-
constructor(level, message, optionalParams = []) {
|
|
12
|
-
this.level = level;
|
|
13
|
-
this.message = message;
|
|
14
|
-
this.optionalParams = optionalParams;
|
|
15
|
-
}
|
|
16
|
-
get key() {
|
|
17
|
-
return `${this.level}_${this.message}_${this.optionalParams.join("_")}`;
|
|
18
|
-
}
|
|
19
|
-
get levelMessageHash() {
|
|
20
|
-
return hashCode(`${this.level}_${this.message}`);
|
|
21
|
-
}
|
|
22
|
-
equals(other) {
|
|
23
|
-
return this.key === other.key;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function notInArray(target, m) {
|
|
27
|
-
return target.every((a) => !a.equals(m));
|
|
28
|
-
}
|
|
29
|
-
export class LogObservable extends AccumulatingObservable {
|
|
30
|
-
constructor() {
|
|
31
|
-
super();
|
|
32
|
-
this.addPrebaked = (m, toConsoleLog = false) => {
|
|
33
|
-
if (notInArray(this.accumulated, m)) {
|
|
34
|
-
this.notifyAll(m);
|
|
35
|
-
}
|
|
36
|
-
if (toConsoleLog) {
|
|
37
|
-
const message = m.message;
|
|
38
|
-
const optionalParams = m.optionalParams;
|
|
39
|
-
switch (m.level) {
|
|
40
|
-
case LogLevel.Info:
|
|
41
|
-
console.info(message, ...optionalParams);
|
|
42
|
-
break;
|
|
43
|
-
case LogLevel.Warn:
|
|
44
|
-
console.warn(message, ...optionalParams);
|
|
45
|
-
break;
|
|
46
|
-
case LogLevel.Error:
|
|
47
|
-
console.error(message, ...optionalParams);
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
console.log(message, ...optionalParams);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
this.someLog = (level, message, ...optionalParams) => {
|
|
55
|
-
this.addPrebaked(new LogMessage(level, message, optionalParams), true);
|
|
56
|
-
};
|
|
57
|
-
LogObservable._allObservables.push(this);
|
|
58
|
-
}
|
|
59
|
-
static get accumulate() {
|
|
60
|
-
return this._accumulate;
|
|
61
|
-
}
|
|
62
|
-
static set accumulate(v) {
|
|
63
|
-
this._accumulate = v;
|
|
64
|
-
if (!v) {
|
|
65
|
-
this.clear();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
static get allMessages() {
|
|
69
|
-
return this._allObservables.reduce((a, o) => {
|
|
70
|
-
o.accumulated.forEach((m) => {
|
|
71
|
-
if (notInArray(a, m)) {
|
|
72
|
-
a.push(m);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return a;
|
|
76
|
-
}, []);
|
|
77
|
-
}
|
|
78
|
-
static clear() {
|
|
79
|
-
for (const o of this._allObservables) {
|
|
80
|
-
o.clear();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
info(message, ...optionalParams) {
|
|
84
|
-
this.someLog(LogLevel.Info, message, ...optionalParams);
|
|
85
|
-
}
|
|
86
|
-
warn(message, ...optionalParams) {
|
|
87
|
-
this.someLog(LogLevel.Warn, message, ...optionalParams);
|
|
88
|
-
}
|
|
89
|
-
warnFromCaught(e) {
|
|
90
|
-
this.warn(`${e}`);
|
|
91
|
-
}
|
|
92
|
-
error(message, ...optionalParams) {
|
|
93
|
-
this.someLog(LogLevel.Error, message, ...optionalParams);
|
|
94
|
-
}
|
|
95
|
-
errorFromCaught(e) {
|
|
96
|
-
this.error(`${e}`);
|
|
97
|
-
}
|
|
98
|
-
errorAsObject(message, ...optionalParams) {
|
|
99
|
-
this.someLog(LogLevel.Error, message, ...optionalParams);
|
|
100
|
-
return new Error(message + "\n " + optionalParams.join("a"));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
LogObservable._allObservables = [];
|
|
104
|
-
LogObservable._accumulate = true;
|
|
1
|
+
import { hashCode } from "../index.js";
|
|
2
|
+
import { AccumulatingObservable } from "./AccumulatingObservable.js";
|
|
3
|
+
export var LogLevel;
|
|
4
|
+
(function (LogLevel) {
|
|
5
|
+
LogLevel["Log"] = "Log";
|
|
6
|
+
LogLevel["Info"] = "Info";
|
|
7
|
+
LogLevel["Warn"] = "Warn";
|
|
8
|
+
LogLevel["Error"] = "Error";
|
|
9
|
+
})(LogLevel || (LogLevel = {}));
|
|
10
|
+
export class LogMessage {
|
|
11
|
+
constructor(level, message, optionalParams = []) {
|
|
12
|
+
this.level = level;
|
|
13
|
+
this.message = message;
|
|
14
|
+
this.optionalParams = optionalParams;
|
|
15
|
+
}
|
|
16
|
+
get key() {
|
|
17
|
+
return `${this.level}_${this.message}_${this.optionalParams.join("_")}`;
|
|
18
|
+
}
|
|
19
|
+
get levelMessageHash() {
|
|
20
|
+
return hashCode(`${this.level}_${this.message}`);
|
|
21
|
+
}
|
|
22
|
+
equals(other) {
|
|
23
|
+
return this.key === other.key;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function notInArray(target, m) {
|
|
27
|
+
return target.every((a) => !a.equals(m));
|
|
28
|
+
}
|
|
29
|
+
export class LogObservable extends AccumulatingObservable {
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this.addPrebaked = (m, toConsoleLog = false) => {
|
|
33
|
+
if (notInArray(this.accumulated, m)) {
|
|
34
|
+
this.notifyAll(m);
|
|
35
|
+
}
|
|
36
|
+
if (toConsoleLog) {
|
|
37
|
+
const message = m.message;
|
|
38
|
+
const optionalParams = m.optionalParams;
|
|
39
|
+
switch (m.level) {
|
|
40
|
+
case LogLevel.Info:
|
|
41
|
+
console.info(message, ...optionalParams);
|
|
42
|
+
break;
|
|
43
|
+
case LogLevel.Warn:
|
|
44
|
+
console.warn(message, ...optionalParams);
|
|
45
|
+
break;
|
|
46
|
+
case LogLevel.Error:
|
|
47
|
+
console.error(message, ...optionalParams);
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
console.log(message, ...optionalParams);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
this.someLog = (level, message, ...optionalParams) => {
|
|
55
|
+
this.addPrebaked(new LogMessage(level, message, optionalParams), true);
|
|
56
|
+
};
|
|
57
|
+
LogObservable._allObservables.push(this);
|
|
58
|
+
}
|
|
59
|
+
static get accumulate() {
|
|
60
|
+
return this._accumulate;
|
|
61
|
+
}
|
|
62
|
+
static set accumulate(v) {
|
|
63
|
+
this._accumulate = v;
|
|
64
|
+
if (!v) {
|
|
65
|
+
this.clear();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
static get allMessages() {
|
|
69
|
+
return this._allObservables.reduce((a, o) => {
|
|
70
|
+
o.accumulated.forEach((m) => {
|
|
71
|
+
if (notInArray(a, m)) {
|
|
72
|
+
a.push(m);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return a;
|
|
76
|
+
}, []);
|
|
77
|
+
}
|
|
78
|
+
static clear() {
|
|
79
|
+
for (const o of this._allObservables) {
|
|
80
|
+
o.clear();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
info(message, ...optionalParams) {
|
|
84
|
+
this.someLog(LogLevel.Info, message, ...optionalParams);
|
|
85
|
+
}
|
|
86
|
+
warn(message, ...optionalParams) {
|
|
87
|
+
this.someLog(LogLevel.Warn, message, ...optionalParams);
|
|
88
|
+
}
|
|
89
|
+
warnFromCaught(e) {
|
|
90
|
+
this.warn(`${e}`);
|
|
91
|
+
}
|
|
92
|
+
error(message, ...optionalParams) {
|
|
93
|
+
this.someLog(LogLevel.Error, message, ...optionalParams);
|
|
94
|
+
}
|
|
95
|
+
errorFromCaught(e) {
|
|
96
|
+
this.error(`${e}`);
|
|
97
|
+
}
|
|
98
|
+
errorAsObject(message, ...optionalParams) {
|
|
99
|
+
this.someLog(LogLevel.Error, message, ...optionalParams);
|
|
100
|
+
return new Error(message + "\n " + optionalParams.join("a"));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
LogObservable._allObservables = [];
|
|
104
|
+
LogObservable._accumulate = true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LogObservable } from "./LogObservable.js";
|
|
2
|
-
export interface LogProducer {
|
|
3
|
-
logger: LogObservable;
|
|
4
|
-
}
|
|
5
|
-
export declare function isLogProducer(object: unknown): object is LogProducer;
|
|
1
|
+
import { LogObservable } from "./LogObservable.js";
|
|
2
|
+
export interface LogProducer {
|
|
3
|
+
logger: LogObservable;
|
|
4
|
+
}
|
|
5
|
+
export declare function isLogProducer(object: unknown): object is LogProducer;
|
|
6
6
|
//# sourceMappingURL=LogProducer.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LogObservable } from "./LogObservable.js";
|
|
2
|
-
function hasLoggerProperty(object) {
|
|
3
|
-
return typeof object === "object" && object !== null && "logger" in object;
|
|
4
|
-
}
|
|
5
|
-
// This has to be possible to do without the helper function and the HasLoggerProperty
|
|
6
|
-
// but can't figure out how right now
|
|
7
|
-
export function isLogProducer(object) {
|
|
8
|
-
return hasLoggerProperty(object) && object.logger instanceof LogObservable;
|
|
9
|
-
}
|
|
1
|
+
import { LogObservable } from "./LogObservable.js";
|
|
2
|
+
function hasLoggerProperty(object) {
|
|
3
|
+
return typeof object === "object" && object !== null && "logger" in object;
|
|
4
|
+
}
|
|
5
|
+
// This has to be possible to do without the helper function and the HasLoggerProperty
|
|
6
|
+
// but can't figure out how right now
|
|
7
|
+
export function isLogProducer(object) {
|
|
8
|
+
return hasLoggerProperty(object) && object.logger instanceof LogObservable;
|
|
9
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare class Observable<T> {
|
|
2
|
-
listeners: {
|
|
3
|
-
l: (v: T) => void;
|
|
4
|
-
c: unknown | undefined;
|
|
5
|
-
}[];
|
|
6
|
-
listen: (listener: (v: T) => void, context?: unknown) => void;
|
|
7
|
-
stopListen: (listener: (v: T) => void) => void;
|
|
8
|
-
stopAllListen: () => void;
|
|
9
|
-
notifyAll: (v: T, context?: unknown) => void;
|
|
10
|
-
link: (other: Observable<T>) => void;
|
|
11
|
-
unlink: (other: Observable<T>) => void;
|
|
12
|
-
}
|
|
1
|
+
export declare class Observable<T> {
|
|
2
|
+
listeners: {
|
|
3
|
+
l: (v: T) => void;
|
|
4
|
+
c: unknown | undefined;
|
|
5
|
+
}[];
|
|
6
|
+
listen: (listener: (v: T) => void, context?: unknown) => void;
|
|
7
|
+
stopListen: (listener: (v: T) => void) => void;
|
|
8
|
+
stopAllListen: () => void;
|
|
9
|
+
notifyAll: (v: T, context?: unknown) => void;
|
|
10
|
+
link: (other: Observable<T>) => void;
|
|
11
|
+
unlink: (other: Observable<T>) => void;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=Observable.d.ts.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
export class Observable {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.listeners = [];
|
|
4
|
-
this.listen = (listener, context) => {
|
|
5
|
-
this.listeners.push({ l: listener, c: context });
|
|
6
|
-
};
|
|
7
|
-
this.stopListen = (listener) => {
|
|
8
|
-
const index = this.listeners.findIndex((l) => l.l === listener);
|
|
9
|
-
if (index !== -1) {
|
|
10
|
-
this.listeners.splice(index, 1);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
this.stopAllListen = () => {
|
|
14
|
-
this.listeners.length = 0;
|
|
15
|
-
};
|
|
16
|
-
this.notifyAll = (v, context) => {
|
|
17
|
-
this.listeners.forEach((l) => {
|
|
18
|
-
if (context && l.c === context) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
l.l(v);
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
this.link = (other) => {
|
|
25
|
-
this.listen((v) => other.notifyAll(v, this), other);
|
|
26
|
-
other.listen((v) => this.notifyAll(v, other), this);
|
|
27
|
-
};
|
|
28
|
-
this.unlink = (other) => {
|
|
29
|
-
this.stopListen(other.notifyAll);
|
|
30
|
-
other.stopListen(this.notifyAll);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
export class Observable {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.listeners = [];
|
|
4
|
+
this.listen = (listener, context) => {
|
|
5
|
+
this.listeners.push({ l: listener, c: context });
|
|
6
|
+
};
|
|
7
|
+
this.stopListen = (listener) => {
|
|
8
|
+
const index = this.listeners.findIndex((l) => l.l === listener);
|
|
9
|
+
if (index !== -1) {
|
|
10
|
+
this.listeners.splice(index, 1);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
this.stopAllListen = () => {
|
|
14
|
+
this.listeners.length = 0;
|
|
15
|
+
};
|
|
16
|
+
this.notifyAll = (v, context) => {
|
|
17
|
+
this.listeners.forEach((l) => {
|
|
18
|
+
if (context && l.c === context) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
l.l(v);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
this.link = (other) => {
|
|
25
|
+
this.listen((v) => other.notifyAll(v, this), other);
|
|
26
|
+
other.listen((v) => this.notifyAll(v, other), this);
|
|
27
|
+
};
|
|
28
|
+
this.unlink = (other) => {
|
|
29
|
+
this.stopListen(other.notifyAll);
|
|
30
|
+
other.stopListen(this.notifyAll);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
package/dist/PromiseCache.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GenericCache } from "./GenericCache.js";
|
|
2
|
-
export declare class PromiseCache<Key, Item> extends GenericCache<Key, Promise<Item>> {
|
|
3
|
-
get(key: Key, createMissing: () => Promise<Item>): Promise<Item>;
|
|
4
|
-
}
|
|
1
|
+
import { GenericCache } from "./GenericCache.js";
|
|
2
|
+
export declare class PromiseCache<Key, Item> extends GenericCache<Key, Promise<Item>> {
|
|
3
|
+
get(key: Key, createMissing: () => Promise<Item>): Promise<Item>;
|
|
4
|
+
}
|
|
5
5
|
//# sourceMappingURL=PromiseCache.d.ts.map
|
package/dist/PromiseCache.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { GenericCache } from "./GenericCache.js";
|
|
11
|
-
export class PromiseCache extends GenericCache {
|
|
12
|
-
get(key, createMissing) {
|
|
13
|
-
const _super = Object.create(null, {
|
|
14
|
-
get: { get: () => super.get }
|
|
15
|
-
});
|
|
16
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
return _super.get.call(this, key, () => {
|
|
18
|
-
const item = createMissing();
|
|
19
|
-
if (item !== undefined) {
|
|
20
|
-
item.catch(() => {
|
|
21
|
-
this.delete(key);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return item;
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { GenericCache } from "./GenericCache.js";
|
|
11
|
+
export class PromiseCache extends GenericCache {
|
|
12
|
+
get(key, createMissing) {
|
|
13
|
+
const _super = Object.create(null, {
|
|
14
|
+
get: { get: () => super.get }
|
|
15
|
+
});
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
return _super.get.call(this, key, () => {
|
|
18
|
+
const item = createMissing();
|
|
19
|
+
if (item !== undefined) {
|
|
20
|
+
item.catch(() => {
|
|
21
|
+
this.delete(key);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return item;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
package/dist/assert.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @throws error with the supplied message, if the condition is not true.
|
|
3
|
-
*
|
|
4
|
-
* Can for example be used like a type guard in TypeScript.
|
|
5
|
-
*/
|
|
6
|
-
export declare function assert(condition: unknown, msg?: string): asserts condition;
|
|
7
|
-
/**
|
|
8
|
-
* @throws error with the supplied message, if the value === undefined.
|
|
9
|
-
*
|
|
10
|
-
* Can be used like a type guard in TypeScript.
|
|
11
|
-
*/
|
|
12
|
-
export declare function assertDefined<T>(value: T, msg?: string): asserts value is Exclude<T, undefined>;
|
|
1
|
+
/**
|
|
2
|
+
* @throws error with the supplied message, if the condition is not true.
|
|
3
|
+
*
|
|
4
|
+
* Can for example be used like a type guard in TypeScript.
|
|
5
|
+
*/
|
|
6
|
+
export declare function assert(condition: unknown, msg?: string): asserts condition;
|
|
7
|
+
/**
|
|
8
|
+
* @throws error with the supplied message, if the value === undefined.
|
|
9
|
+
*
|
|
10
|
+
* Can be used like a type guard in TypeScript.
|
|
11
|
+
*/
|
|
12
|
+
export declare function assertDefined<T>(value: T, msg?: string): asserts value is Exclude<T, undefined>;
|
|
13
13
|
//# sourceMappingURL=assert.d.ts.map
|
package/dist/assert.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @throws error with the supplied message, if the condition is not true.
|
|
3
|
-
*
|
|
4
|
-
* Can for example be used like a type guard in TypeScript.
|
|
5
|
-
*/
|
|
6
|
-
export function assert(condition, msg) {
|
|
7
|
-
if (!condition) {
|
|
8
|
-
throw new Error(msg);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @throws error with the supplied message, if the value === undefined.
|
|
13
|
-
*
|
|
14
|
-
* Can be used like a type guard in TypeScript.
|
|
15
|
-
*/
|
|
16
|
-
export function assertDefined(value, msg) {
|
|
17
|
-
if (value === undefined) {
|
|
18
|
-
throw new Error(msg);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @throws error with the supplied message, if the condition is not true.
|
|
3
|
+
*
|
|
4
|
+
* Can for example be used like a type guard in TypeScript.
|
|
5
|
+
*/
|
|
6
|
+
export function assert(condition, msg) {
|
|
7
|
+
if (!condition) {
|
|
8
|
+
throw new Error(msg);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @throws error with the supplied message, if the value === undefined.
|
|
13
|
+
*
|
|
14
|
+
* Can be used like a type guard in TypeScript.
|
|
15
|
+
*/
|
|
16
|
+
export function assertDefined(value, msg) {
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
throw new Error(msg);
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/cmMips.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { LogObservable } from "./Observable/LogObservable.js";
|
|
2
|
-
/** The mime type (or media type) is only used internally, so using the "x." sub type is OK. */
|
|
3
|
-
export declare const CMMIPS_MIMETYPE = "image/x.cmmips";
|
|
4
|
-
/**
|
|
5
|
-
* Extracts the specified MIP level image data from the CmMips container.
|
|
6
|
-
*
|
|
7
|
-
* By default the highest quality MIP level is loaded. The optional maxResolution setting will
|
|
8
|
-
* instead load the highest quality MIP level where BOTH width and height is < maxResolution, or
|
|
9
|
-
* the lowest quality if none fulfill the requirement.
|
|
10
|
-
*
|
|
11
|
-
* Returns a filled in CmMips class with meta data as well as the byte array with the image data.
|
|
12
|
-
* Returns undefined if there was an error
|
|
13
|
-
*
|
|
14
|
-
* @warning: For efficacy and maximum flexibility, the returned Uint8Array is only a new View into
|
|
15
|
-
* the supplied bytes typed array. It is up to the caller to call slice() on it to create a copy of
|
|
16
|
-
* the data if needed.
|
|
17
|
-
*/
|
|
18
|
-
export declare function extractCmMips(bytes: Uint8Array, logger: LogObservable, maxRes?: number): CmMip | undefined;
|
|
19
|
-
export declare class CmMip {
|
|
20
|
-
readonly name: string;
|
|
21
|
-
readonly suffix: string;
|
|
22
|
-
readonly width: number;
|
|
23
|
-
readonly height: number;
|
|
24
|
-
readonly data?: Uint8Array | undefined;
|
|
25
|
-
constructor(name: string, suffix: string, width: number, height: number, data?: Uint8Array | undefined);
|
|
26
|
-
}
|
|
1
|
+
import { LogObservable } from "./Observable/LogObservable.js";
|
|
2
|
+
/** The mime type (or media type) is only used internally, so using the "x." sub type is OK. */
|
|
3
|
+
export declare const CMMIPS_MIMETYPE = "image/x.cmmips";
|
|
4
|
+
/**
|
|
5
|
+
* Extracts the specified MIP level image data from the CmMips container.
|
|
6
|
+
*
|
|
7
|
+
* By default the highest quality MIP level is loaded. The optional maxResolution setting will
|
|
8
|
+
* instead load the highest quality MIP level where BOTH width and height is < maxResolution, or
|
|
9
|
+
* the lowest quality if none fulfill the requirement.
|
|
10
|
+
*
|
|
11
|
+
* Returns a filled in CmMips class with meta data as well as the byte array with the image data.
|
|
12
|
+
* Returns undefined if there was an error
|
|
13
|
+
*
|
|
14
|
+
* @warning: For efficacy and maximum flexibility, the returned Uint8Array is only a new View into
|
|
15
|
+
* the supplied bytes typed array. It is up to the caller to call slice() on it to create a copy of
|
|
16
|
+
* the data if needed.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractCmMips(bytes: Uint8Array, logger: LogObservable, maxRes?: number): CmMip | undefined;
|
|
19
|
+
export declare class CmMip {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly suffix: string;
|
|
22
|
+
readonly width: number;
|
|
23
|
+
readonly height: number;
|
|
24
|
+
readonly data?: Uint8Array | undefined;
|
|
25
|
+
constructor(name: string, suffix: string, width: number, height: number, data?: Uint8Array | undefined);
|
|
26
|
+
}
|
|
27
27
|
//# sourceMappingURL=cmMips.d.ts.map
|