strata.foundation.core 0.0.5 → 0.0.6

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.
Files changed (35) hide show
  1. package/Concurrent/CompletableObservable.d.ts +24 -0
  2. package/Concurrent/CompletableObservable.js +54 -66
  3. package/Concurrent/CompletableObservable.js.map +1 -0
  4. package/Concurrent/CompletionContext.d.ts +19 -0
  5. package/Concurrent/CompletionContext.js +35 -33
  6. package/Concurrent/CompletionContext.js.map +1 -0
  7. package/Concurrent/CompletionError.d.ts +5 -0
  8. package/Concurrent/CompletionError.js +10 -26
  9. package/Concurrent/CompletionError.js.map +1 -0
  10. package/Concurrent/ICompletionStage.d.ts +7 -0
  11. package/Concurrent/ICompletionStage.js +1 -0
  12. package/Concurrent/ICompletionStage.js.map +1 -0
  13. package/Concurrent/index.d.ts +4 -0
  14. package/{index.js → Concurrent/index.js} +5 -6
  15. package/Concurrent/index.js.map +1 -0
  16. package/Container/IMultiMap.d.ts +12 -0
  17. package/Container/IMultiMap.js +3 -2
  18. package/Container/IMultiMap.js.map +1 -1
  19. package/Container/MultiMap.d.ts +15 -0
  20. package/Container/MultiMap.js +24 -23
  21. package/Container/MultiMap.js.map +1 -1
  22. package/Container/index.d.ts +2 -0
  23. package/Container/index.js +6 -0
  24. package/Container/index.js.map +1 -0
  25. package/package.json +10 -22
  26. package/strata.foundation.core-v0.0.6.tgz +0 -0
  27. package/Concurrent/CompletableObservable.ts +0 -218
  28. package/Concurrent/CompletionContext.ts +0 -106
  29. package/Concurrent/CompletionError.ts +0 -17
  30. package/Concurrent/ICompletionStage.ts +0 -14
  31. package/Container/IMultiMap.ts +0 -24
  32. package/Container/MultiMap.ts +0 -86
  33. package/index.ts +0 -7
  34. package/strata.foundation.core-0.0.4.tgz +0 -0
  35. package/tsconfig.json +0 -18
@@ -0,0 +1,24 @@
1
+ import { ICompletionStage } from "./ICompletionStage";
2
+ import { Observable } from "rxjs";
3
+ import { CompletionContext } from "./CompletionContext";
4
+ import { CompletionError } from "./CompletionError";
5
+ export declare class CompletableObservable<T> implements ICompletionStage<T> {
6
+ private observable;
7
+ protected constructor(observable: Observable<T> | Observable<CompletionContext<T>>, hasContext?: boolean);
8
+ thenApply<U>(func: (input: T) => U): ICompletionStage<U>;
9
+ thenCompose<U>(func: (input: T) => ICompletionStage<U>): ICompletionStage<U>;
10
+ thenAccept(consumer: (input: T) => void, handler?: (error: Error) => void): ICompletionStage<T>;
11
+ exceptionally(func: (error: Error) => T): ICompletionStage<T>;
12
+ subscribe(consumer?: (result: T) => void, handler?: (error: CompletionError) => void): void;
13
+ static fromResult<U>(result: U): ICompletionStage<U>;
14
+ static fromObservable<U>(observable: Observable<U>): ICompletionStage<U>;
15
+ static fromPromise<U>(promise: Promise<U>): ICompletionStage<U>;
16
+ static fromError<U>(error: Error): ICompletionStage<U>;
17
+ static supplyAsync<U>(supplier: () => U): ICompletionStage<U>;
18
+ private initializeObservable;
19
+ private doApply;
20
+ private doCompose;
21
+ private doAccept;
22
+ private doExceptionally;
23
+ private toObservable;
24
+ }
@@ -1,82 +1,72 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CompletableObservable = void 0;
4
- var rxjs_1 = require("rxjs");
5
- var operators_1 = require("rxjs/operators");
6
- var CompletionContext_1 = require("./CompletionContext");
7
- var CompletionError_1 = require("./CompletionError");
8
- var CompletableObservable = /** @class */ (function () {
9
- function CompletableObservable(observable, hasContext) {
10
- if (hasContext === void 0) { hasContext = false; }
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const CompletionContext_1 = require("./CompletionContext");
7
+ const CompletionError_1 = require("./CompletionError");
8
+ class CompletableObservable {
9
+ observable;
10
+ constructor(observable, hasContext = false) {
11
11
  if (hasContext)
12
12
  this.observable = observable;
13
13
  else
14
14
  this.observable = this.initializeObservable(observable);
15
15
  }
16
- CompletableObservable.prototype.thenApply = function (func) {
17
- var _this = this;
16
+ thenApply(func) {
18
17
  return new CompletableObservable(this
19
18
  .observable
20
- .pipe((0, operators_1.map)(function (context) { return _this.doApply(context, func); })), true);
21
- };
22
- CompletableObservable.prototype.thenCompose = function (func) {
23
- var _this = this;
19
+ .pipe((0, operators_1.map)(context => this.doApply(context, func))), true);
20
+ }
21
+ thenCompose(func) {
24
22
  return new CompletableObservable(this
25
23
  .observable
26
- .pipe(
27
- // @ts-ignore
28
- (0, operators_1.mergeMap)(function (context, i) {
29
- return _this.toObservable(_this.doCompose(func, context))
30
- .pipe((0, operators_1.map)(function (context) { return context; }));
31
- })), true);
32
- };
33
- CompletableObservable.prototype.thenAccept = function (consumer, handler) {
34
- var _this = this;
24
+ .pipe((0, operators_1.mergeMap)(context => this.toObservable(this.doCompose(func, context))
25
+ .pipe((0, operators_1.map)(context => context)))), true);
26
+ }
27
+ thenAccept(consumer, handler) {
35
28
  return new CompletableObservable(this
36
29
  .observable
37
- .pipe((0, operators_1.map)(function (context) { return _this.doAccept(context, consumer, handler); })), true);
38
- };
39
- CompletableObservable.prototype.exceptionally = function (func) {
40
- var _this = this;
30
+ .pipe((0, operators_1.map)(context => this.doAccept(context, consumer, handler))), true);
31
+ }
32
+ exceptionally(func) {
41
33
  return new CompletableObservable(this
42
34
  .observable
43
- .pipe((0, operators_1.map)(function (context) { return _this.doExceptionally(context, func); })), true);
44
- };
45
- CompletableObservable.prototype.subscribe = function (consumer, handler) {
35
+ .pipe((0, operators_1.map)(context => this.doExceptionally(context, func))), true);
36
+ }
37
+ subscribe(consumer, handler) {
46
38
  if (consumer == null)
47
- consumer = function (result) { };
39
+ consumer = result => { };
48
40
  if (handler == null)
49
- handler = function (error) { };
41
+ handler = error => { };
50
42
  this
51
43
  .observable
52
- .subscribe(function (context) {
44
+ .subscribe(context => {
53
45
  if (context.hasError())
54
46
  handler(context.getError());
55
47
  else
56
48
  consumer(context.getResult());
57
- }, function (error) { return handler(error); });
58
- };
59
- CompletableObservable.fromResult = function (result) {
49
+ }, error => handler(error));
50
+ }
51
+ static fromResult(result) {
60
52
  return new CompletableObservable((0, rxjs_1.of)(result), false);
61
- };
62
- CompletableObservable.fromObservable = function (observable) {
53
+ }
54
+ static fromObservable(observable) {
63
55
  return new CompletableObservable(observable, false);
64
- };
65
- CompletableObservable.fromPromise = function (promise) {
56
+ }
57
+ static fromPromise(promise) {
66
58
  return new CompletableObservable((0, rxjs_1.from)(promise), false);
67
- };
68
- CompletableObservable.fromError = function (error) {
69
- return new CompletableObservable(new rxjs_1.Observable(function (observer) {
70
- return observer.next(CompletionContext_1.CompletionContext.ofError(new CompletionError_1.CompletionError(error)));
71
- }), true);
72
- };
73
- CompletableObservable.supplyAsync = function (supplier) {
74
- return new CompletableObservable(new rxjs_1.Observable(function (observer) { return observer.next(supplier()); }), false);
75
- };
76
- CompletableObservable.prototype.initializeObservable = function (input) {
77
- return input.pipe((0, operators_1.map)(function (value) { return CompletionContext_1.CompletionContext.ofResult(value); }));
78
- };
79
- CompletableObservable.prototype.doApply = function (context, func) {
59
+ }
60
+ static fromError(error) {
61
+ return new CompletableObservable(new rxjs_1.Observable(observer => observer.next(CompletionContext_1.CompletionContext.ofError(new CompletionError_1.CompletionError(error)))), true);
62
+ }
63
+ static supplyAsync(supplier) {
64
+ return new CompletableObservable(new rxjs_1.Observable(observer => observer.next(supplier())), false);
65
+ }
66
+ initializeObservable(input) {
67
+ return input.pipe((0, operators_1.map)(value => CompletionContext_1.CompletionContext.ofResult(value)));
68
+ }
69
+ doApply(context, func) {
80
70
  console.log("doApply");
81
71
  if (context.hasError())
82
72
  return CompletionContext_1.CompletionContext.ofError(context.getError());
@@ -87,8 +77,8 @@ var CompletableObservable = /** @class */ (function () {
87
77
  console.log("Caught exception in doApply");
88
78
  return CompletionContext_1.CompletionContext.ofError(new CompletionError_1.CompletionError(e));
89
79
  }
90
- };
91
- CompletableObservable.prototype.doCompose = function (func, context) {
80
+ }
81
+ doCompose(func, context) {
92
82
  console.log("doCompose");
93
83
  if (context.hasError())
94
84
  return CompletionContext_1.CompletionContext.ofError(context.getError());
@@ -99,8 +89,8 @@ var CompletableObservable = /** @class */ (function () {
99
89
  console.log("Caught exception in doCompose");
100
90
  return CompletionContext_1.CompletionContext.ofError(e);
101
91
  }
102
- };
103
- CompletableObservable.prototype.doAccept = function (context, consumer, handler) {
92
+ }
93
+ doAccept(context, consumer, handler) {
104
94
  console.log("doAccept");
105
95
  if (context.hasError()) {
106
96
  if (handler != null) {
@@ -122,20 +112,18 @@ var CompletableObservable = /** @class */ (function () {
122
112
  }
123
113
  }
124
114
  return context;
125
- };
126
- CompletableObservable.prototype.doExceptionally = function (context, func) {
115
+ }
116
+ doExceptionally(context, func) {
127
117
  console.log("doExceptionally");
128
118
  if (context.hasError())
129
119
  return CompletionContext_1.CompletionContext.ofResult(func(context.getError()));
130
120
  return context;
131
- };
132
- CompletableObservable.prototype.toObservable = function (input) {
121
+ }
122
+ toObservable(input) {
133
123
  if (input.hasResult())
134
124
  return input.getResult().observable;
135
- return this.observable.pipe((0, operators_1.map)(function (context, ignore) {
136
- return CompletionContext_1.CompletionContext.ofError(input.getError());
137
- }));
138
- };
139
- return CompletableObservable;
140
- }());
125
+ return this.observable.pipe((0, operators_1.map)((context, ignore) => CompletionContext_1.CompletionContext.ofError(input.getError())));
126
+ }
127
+ }
141
128
  exports.CompletableObservable = CompletableObservable;
129
+ //# sourceMappingURL=CompletableObservable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompletableObservable.js","sourceRoot":"","sources":["../../../main/typescript/Concurrent/CompletableObservable.ts"],"names":[],"mappings":";;;AACA,+BAAwC;AACxC,8CAA4C;AAC5C,2DAAsD;AACtD,uDAAkD;AAElD,MACM,qBAAqB;IAGf,UAAU,CAAmC;IAErD,YACI,UAA0D,EAC1D,aAAsB,KAAK;QAE3B,IAAI,UAAU;YACV,IAAI,CAAC,UAAU,GAAqC,UAAU,CAAC;;YAE/D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,C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EACtB;YACI,IAAI,OAAO,IAAI,IAAI,EACnB;gBACI,IACA;oBACI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAC/B;gBACD,OAAO,CAAC,EACR;oBACI,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;oBAC5C,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,iCAAe,CAAC,CAAC,CAAC,CAAC,CAAC;iBACnD;aACJ;SACJ;aAED;YACI,IACA;gBACI,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;aACjC;YACD,OAAO,CAAC,EACR;gBACI,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,iCAAe,CAAC,CAAC,CAAC,CAAC,CAAC;aACnD;SACJ;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAEO,eAAe,CAAC,OAA6B,EAAC,IAAyB;QAE3E,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,IAAI,OAAO,CAAC,QAAQ,EAAE;YAClB,OAAO,qCAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAEhE,OAAO,OAAO,CAAC;IACnB,CAAC;IAEO,YAAY,CAAI,KAA6C;QAEjE,IAAI,KAAK,CAAC,SAAS,EAAE;YACjB,OAAkC,KAAK,CAAC,SAAS,EAAG,CAAC,UAAU,CAAC;QAEpE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACvB,IAAA,eAAG,EACC,CAAC,OAAO,EAAC,MAAM,EAAE,EAAE,CACf,qCAAiB,CAAC,OAAO,CAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAA;IAChE,CAAC;CACJ;AAnND,sDAmNC"}
@@ -0,0 +1,19 @@
1
+ import { CompletionError } from "./CompletionError";
2
+ export declare class CompletionContext<T> {
3
+ private result;
4
+ private error;
5
+ protected constructor(result: T, error: CompletionError);
6
+ setResult(result: T): CompletionContext<T>;
7
+ clearResult(): CompletionContext<T>;
8
+ setError(error: CompletionError): CompletionContext<T>;
9
+ clearError(): CompletionContext<T>;
10
+ getResult(): T;
11
+ getError(): CompletionError;
12
+ hasResult(): boolean;
13
+ hasError(): boolean;
14
+ combine(other: CompletionContext<T>, combiner: (x: T, y: T) => T): CompletionContext<T>;
15
+ accept(consumer: (context: CompletionContext<T>) => void): CompletionContext<T>;
16
+ static empty<T>(): CompletionContext<T>;
17
+ static ofResult<T>(result: T): CompletionContext<T>;
18
+ static ofError<T>(error: CompletionError): CompletionContext<T>;
19
+ }
@@ -1,44 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CompletionContext = void 0;
4
- var CompletionError_1 = require("./CompletionError");
5
- var CompletionContext = /** @class */ (function () {
6
- function CompletionContext(result, error) {
4
+ const CompletionError_1 = require("./CompletionError");
5
+ class CompletionContext {
6
+ result;
7
+ error;
8
+ constructor(result, error) {
7
9
  this.result = result;
8
10
  this.error = error;
9
11
  }
10
- CompletionContext.prototype.setResult = function (result) {
12
+ setResult(result) {
11
13
  this.result = result;
12
14
  return this;
13
- };
14
- CompletionContext.prototype.clearResult = function () {
15
+ }
16
+ clearResult() {
15
17
  this.result = null;
16
18
  return this;
17
- };
18
- CompletionContext.prototype.setError = function (error) {
19
+ }
20
+ setError(error) {
19
21
  this.error = error;
20
22
  return this;
21
- };
22
- CompletionContext.prototype.clearError = function () {
23
+ }
24
+ clearError() {
23
25
  this.error = null;
24
26
  return this;
25
- };
26
- CompletionContext.prototype.getResult = function () {
27
+ }
28
+ getResult() {
27
29
  return this.result;
28
- };
29
- CompletionContext.prototype.getError = function () {
30
+ }
31
+ getError() {
30
32
  return this.error;
31
- };
32
- CompletionContext.prototype.hasResult = function () {
33
+ }
34
+ hasResult() {
33
35
  return this.result != null;
34
- };
35
- CompletionContext.prototype.hasError = function () {
36
+ }
37
+ hasError() {
36
38
  return this.error != null;
37
- };
38
- CompletionContext.prototype.combine = function (other, combiner) {
39
+ }
40
+ combine(other, combiner) {
39
41
  if (this.hasError() || other.hasError()) {
40
- var x = this.getError();
41
- var y = other.getError();
42
+ let x = this.getError();
43
+ let y = other.getError();
42
44
  if (x != null && y != null)
43
45
  return new CompletionContext(combiner(this.getResult(), other.getResult()), new CompletionError_1.CompletionError([x.getCause(), y.getCause()]));
44
46
  else if (x != null)
@@ -49,20 +51,20 @@ var CompletionContext = /** @class */ (function () {
49
51
  else {
50
52
  return CompletionContext.ofResult(combiner(this.getResult(), other.getResult()));
51
53
  }
52
- };
53
- CompletionContext.prototype.accept = function (consumer) {
54
+ }
55
+ accept(consumer) {
54
56
  consumer(this);
55
57
  return this;
56
- };
57
- CompletionContext.empty = function () {
58
+ }
59
+ static empty() {
58
60
  return new CompletionContext(null, null);
59
- };
60
- CompletionContext.ofResult = function (result) {
61
+ }
62
+ static ofResult(result) {
61
63
  return new CompletionContext(result, null);
62
- };
63
- CompletionContext.ofError = function (error) {
64
+ }
65
+ static ofError(error) {
64
66
  return new CompletionContext(null, error);
65
- };
66
- return CompletionContext;
67
- }());
67
+ }
68
+ }
68
69
  exports.CompletionContext = CompletionContext;
70
+ //# sourceMappingURL=CompletionContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompletionContext.js","sourceRoot":"","sources":["../../../main/typescript/Concurrent/CompletionContext.ts"],"names":[],"mappings":";;;AAAA,uDAAkD;AAElD,MACM,iBAAiB;IAEX,MAAM,CAAI;IACV,KAAK,CAAkB;IAE/B,YAAsB,MAAS,EAAC,KAAsB;QAElD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,SAAS,CAAC,MAAS;QAEf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW;QAEP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC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,EAAC,KAAK,CAAC,SAAS,EAAE,CAAC,EAC5C,CAAC,CAAC,CAAC;SACd;aAED;YACI,OAAO,iBAAiB,CAAC,QAAQ,CAC7B,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,EAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;SACrD;IACL,CAAC;IAED,MAAM,CAAC,QAAiD;QAEpD,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,KAAK;QAER,OAAO,IAAI,iBAAiB,CAAI,IAAI,EAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,QAAQ,CAAI,MAAS;QAExB,OAAO,IAAI,iBAAiB,CAAI,MAAM,EAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,OAAO,CAAI,KAAsB;QAEpC,OAAO,IAAI,iBAAiB,CAAI,IAAI,EAAC,KAAK,CAAC,CAAC;IAChD,CAAC;CACJ;AAvGD,8CAuGC"}
@@ -0,0 +1,5 @@
1
+ export declare class CompletionError extends Error {
2
+ private readonly itsCause;
3
+ constructor(cause: any);
4
+ getCause(): any;
5
+ }
@@ -1,31 +1,15 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.CompletionError = void 0;
19
- var CompletionError = /** @class */ (function (_super) {
20
- __extends(CompletionError, _super);
21
- function CompletionError(cause) {
22
- var _this = _super.call(this, cause instanceof Error ? cause.message : cause.toString()) || this;
23
- _this.cause = cause;
24
- return _this;
4
+ class CompletionError extends Error {
5
+ itsCause;
6
+ constructor(cause) {
7
+ super(cause instanceof Error ? cause.message : cause.toString());
8
+ this.itsCause = cause;
25
9
  }
26
- CompletionError.prototype.getCause = function () {
27
- return this.cause;
28
- };
29
- return CompletionError;
30
- }(Error));
10
+ getCause() {
11
+ return this.itsCause;
12
+ }
13
+ }
31
14
  exports.CompletionError = CompletionError;
15
+ //# sourceMappingURL=CompletionError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompletionError.js","sourceRoot":"","sources":["../../../main/typescript/Concurrent/CompletionError.ts"],"names":[],"mappings":";;;AAAA,MACM,eACF,SAAQ,KAAK;IAEI,QAAQ,CAAM;IAE/B,YAAY,KAAU;QAElB,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,QAAQ;QAEJ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAhBD,0CAgBC"}
@@ -0,0 +1,7 @@
1
+ export interface ICompletionStage<T> {
2
+ thenApply<U>(func: (input: T) => U): ICompletionStage<U>;
3
+ thenCompose<U>(func: (input: T) => ICompletionStage<U>): ICompletionStage<U>;
4
+ thenAccept(consumer: (result: T) => void, handler?: (error: Error) => void): ICompletionStage<T>;
5
+ exceptionally(func: (error: Error) => T): ICompletionStage<T>;
6
+ subscribe(consumer?: (result: T) => void, handler?: (error: Error) => void): void;
7
+ }
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ICompletionStage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICompletionStage.js","sourceRoot":"","sources":["../../../main/typescript/Concurrent/ICompletionStage.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export { ICompletionStage } from './ICompletionStage';
2
+ export { CompletableObservable } from './CompletableObservable';
3
+ export { CompletionContext } from './CompletionContext';
4
+ export { CompletionError } from './CompletionError';
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CompletionError = exports.CompletionContext = exports.CompletableObservable = exports.MultiMap = void 0;
4
- var MultiMap_1 = require("./Container/MultiMap");
5
- Object.defineProperty(exports, "MultiMap", { enumerable: true, get: function () { return MultiMap_1.MultiMap; } });
6
- var CompletableObservable_1 = require("./Concurrent/CompletableObservable");
3
+ exports.CompletionError = exports.CompletionContext = exports.CompletableObservable = void 0;
4
+ var CompletableObservable_1 = require("./CompletableObservable");
7
5
  Object.defineProperty(exports, "CompletableObservable", { enumerable: true, get: function () { return CompletableObservable_1.CompletableObservable; } });
8
- var CompletionContext_1 = require("./Concurrent/CompletionContext");
6
+ var CompletionContext_1 = require("./CompletionContext");
9
7
  Object.defineProperty(exports, "CompletionContext", { enumerable: true, get: function () { return CompletionContext_1.CompletionContext; } });
10
- var CompletionError_1 = require("./Concurrent/CompletionError");
8
+ var CompletionError_1 = require("./CompletionError");
11
9
  Object.defineProperty(exports, "CompletionError", { enumerable: true, get: function () { return CompletionError_1.CompletionError; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../main/typescript/Concurrent/index.ts"],"names":[],"mappings":";;;AACA,iEAA8D;AAAtD,8HAAA,qBAAqB,OAAA;AAC7B,yDAAsD;AAA9C,sHAAA,iBAAiB,OAAA;AACzB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA"}
@@ -0,0 +1,12 @@
1
+ export interface IMultiMap<K, V> {
2
+ put(key: K, value: V): IMultiMap<K, V>;
3
+ remove(key: K): IMultiMap<K, V>;
4
+ remove(key: K, value: V): IMultiMap<K, V>;
5
+ get(key: K): Array<V>;
6
+ getAt(key: K, index: number): V;
7
+ getCardinality(key: K): number;
8
+ getKeys(): Array<K>;
9
+ getValues(): Array<Array<V>>;
10
+ containsKey(key: K): boolean;
11
+ containsValue(key: K, value: V): boolean;
12
+ }
@@ -1,2 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IMultiMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IMultiMap.js","sourceRoot":"","sources":["IMultiMap.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"IMultiMap.js","sourceRoot":"","sources":["../../../main/typescript/Container/IMultiMap.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { IMultiMap } from "./IMultiMap";
2
+ export declare class MultiMap<K, V> implements IMultiMap<K, V> {
3
+ private imp;
4
+ constructor();
5
+ put(key: K, value: V): IMultiMap<K, V>;
6
+ remove(key: K): IMultiMap<K, V>;
7
+ remove(key: K, value: V): IMultiMap<K, V>;
8
+ get(key: K): Array<V>;
9
+ getAt(key: K, index: number): V;
10
+ getCardinality(key: K): number;
11
+ getKeys(): Array<K>;
12
+ getValues(): Array<Array<V>>;
13
+ containsKey(key: K): boolean;
14
+ containsValue(key: K, value: V): boolean;
15
+ }
@@ -1,22 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MultiMap = void 0;
4
- var MultiMap = /** @class */ (function () {
5
- function MultiMap() {
4
+ class MultiMap {
5
+ imp;
6
+ constructor() {
6
7
  this.imp = new Map();
7
8
  }
8
- MultiMap.prototype.put = function (key, value) {
9
+ put(key, value) {
9
10
  if (key == null)
10
11
  throw new Error("key is null");
11
12
  if (!this.imp.has(key))
12
13
  this.imp.set(key, new Array());
13
14
  this.imp.get(key).push(value);
14
15
  return this;
15
- };
16
- MultiMap.prototype.remove = function (key, value) {
16
+ }
17
+ remove(key, value) {
17
18
  if (value) {
18
19
  if (this.imp.has(key)) {
19
- var values = this.imp.get(key);
20
+ let values = this.imp.get(key);
20
21
  values.slice(values.indexOf(value), 1);
21
22
  }
22
23
  }
@@ -25,30 +26,30 @@ var MultiMap = /** @class */ (function () {
25
26
  this.imp.delete(key);
26
27
  }
27
28
  return this;
28
- };
29
- MultiMap.prototype.get = function (key) {
29
+ }
30
+ get(key) {
30
31
  return this.imp.get(key);
31
- };
32
- MultiMap.prototype.getAt = function (key, index) {
32
+ }
33
+ getAt(key, index) {
33
34
  return this.imp.get(key)[index];
34
- };
35
- MultiMap.prototype.getCardinality = function (key) {
35
+ }
36
+ getCardinality(key) {
36
37
  return this.imp.get(key).length;
37
- };
38
- MultiMap.prototype.getKeys = function () {
38
+ }
39
+ getKeys() {
39
40
  return Array.from(this.imp.keys());
40
- };
41
- MultiMap.prototype.getValues = function () {
41
+ }
42
+ getValues() {
42
43
  return Array.from(this.imp.values());
43
- };
44
- MultiMap.prototype.containsKey = function (key) {
44
+ }
45
+ containsKey(key) {
45
46
  return this.imp.has(key);
46
- };
47
- MultiMap.prototype.containsValue = function (key, value) {
47
+ }
48
+ containsValue(key, value) {
48
49
  if (this.containsKey(key))
49
50
  return this.get(key).includes(value);
50
51
  return false;
51
- };
52
- return MultiMap;
53
- }());
52
+ }
53
+ }
54
54
  exports.MultiMap = MultiMap;
55
+ //# sourceMappingURL=MultiMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MultiMap.js","sourceRoot":"","sources":["MultiMap.ts"],"names":[],"mappings":";;;AAEA,MACM,QAAQ;IAKV;QAEI,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,EAAc,CAAC;IACrC,CAAC;IAED,GAAG,CAAC,GAAM,EAAE,KAAQ;QAEhB,IAAK,GAAG,IAAI,IAAI;YACZ,M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C,CAAC;QAEzC,OAAO,KAAK,CAAC;IACjB,CAAC;CAEJ;AAnFD,4BAmFC"}
@@ -0,0 +1,2 @@
1
+ export { IMultiMap } from './IMultiMap';
2
+ export { MultiMap } from './MultiMap';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MultiMap = void 0;
4
+ var MultiMap_1 = require("./MultiMap");
5
+ Object.defineProperty(exports, "MultiMap", { enumerable: true, get: function () { return MultiMap_1.MultiMap; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../main/typescript/Container/index.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AAA5B,oGAAA,QAAQ,OAAA"}
package/package.json CHANGED
@@ -1,22 +1,10 @@
1
- {
2
- "name": "strata.foundation.core",
3
- "version": "0.0.5",
4
- "description": "",
5
- "main": "build/dist/index.js",
6
- "types": "build/dist/index.d.ts",
7
- "scripts": {
8
- "clean": "del-cli -f build/dist ./*.tgz",
9
- "build": "npm pack",
10
- "publish-package": "npm publish",
11
- "new-patch": "npm version patch",
12
- "new-minor": "npm version minor",
13
- "new-major": "npm version major",
14
- "test": "echo \"Error: no test specified\" && exit 1"
15
- },
16
- "keywords": [],
17
- "author": "",
18
- "license": "ISC",
19
- "dependencies": {
20
- "rxjs": "^7.8.1"
21
- }
22
- }
1
+ {
2
+ "name": "strata.foundation.core",
3
+ "version": "0.0.6",
4
+ "license": "Apache-2.0",
5
+ "scripts": {
6
+ "increment-major": "npm version major",
7
+ "increment-minor": "npm version minor",
8
+ "increment-patch": "npm version patch"
9
+ }
10
+ }
@@ -1,218 +0,0 @@
1
- import {ICompletionStage} from "./ICompletionStage";
2
- import {from,Observable,of} from "rxjs";
3
- import {map,mergeMap} from 'rxjs/operators';
4
- import {CompletionContext} from "./CompletionContext";
5
- import {CompletionError} from "./CompletionError";
6
-
7
- export
8
- class CompletableObservable<T>
9
- implements ICompletionStage<T>
10
- {
11
- private observable: Observable<CompletionContext<T>>;
12
-
13
- protected constructor(
14
- observable: Observable<T>|Observable<CompletionContext<T>>,
15
- hasContext: boolean = false)
16
- {
17
- if (hasContext)
18
- this.observable = <Observable<CompletionContext<T>>>observable;
19
- else
20
- this.observable = this.initializeObservable(<Observable<T>>observable);
21
-
22
- }
23
-
24
- thenApply<U>(func: (input: T) => U): ICompletionStage<U>
25
- {
26
- return new CompletableObservable<U>(
27
- this
28
- .observable
29
- .pipe(map(context => this.doApply(context,func))),
30
- true);
31
- }
32
-
33
- thenCompose<U>(func: (input: T) => ICompletionStage<U>): ICompletionStage<U>
34
- {
35
- return new CompletableObservable<U>(
36
- this
37
- .observable
38
- .pipe<CompletionContext<U>>(
39
- mergeMap(
40
- context =>
41
- this.toObservable<U>(this.doCompose<U>(func,context))
42
- .pipe(map(context => context)))),
43
- true);
44
- }
45
-
46
- thenAccept(consumer: (input: T) => void,handler?: (error: Error) => void): ICompletionStage<T>
47
- {
48
- return new CompletableObservable<T>(
49
- this
50
- .observable
51
- .pipe(map(context => this.doAccept(context,consumer,handler))),
52
- true);
53
- }
54
-
55
- exceptionally(func: (error: Error) => T): ICompletionStage<T>
56
- {
57
- return new CompletableObservable<T>(
58
- this
59
- .observable
60
- .pipe(
61
- map(context => this.doExceptionally(context,func))),
62
- true);
63
- }
64
-
65
- subscribe(
66
- consumer?: (result: T) => void,
67
- handler?: (error: CompletionError) => void): void
68
- {
69
- if (consumer == null)
70
- consumer = result => {};
71
-
72
- if (handler == null)
73
- handler = error => {};
74
-
75
- this
76
- .observable
77
- .subscribe(
78
- context =>
79
- {
80
- if (context.hasError())
81
- handler(context.getError());
82
- else
83
- consumer(context.getResult());
84
- },
85
- error => handler(error));
86
- }
87
-
88
- static fromResult<U>(result: U): ICompletionStage<U>
89
- {
90
- return new CompletableObservable<U>(of(result),false);
91
- }
92
-
93
- static fromObservable<U>(observable: Observable<U>): ICompletionStage<U>
94
- {
95
- return new CompletableObservable<U>(observable,false);
96
- }
97
-
98
- static fromPromise<U>(promise: Promise<U>): ICompletionStage<U>
99
- {
100
- return new CompletableObservable<U>(<Observable<U>>from(promise),false);
101
- }
102
-
103
- static fromError<U>(error: Error): ICompletionStage<U>
104
- {
105
- return new CompletableObservable<U>(
106
- new Observable<CompletionContext<U>>(
107
- observer =>
108
- observer.next(
109
- CompletionContext.ofError<U>(
110
- new CompletionError(error)))),
111
- true);
112
- }
113
-
114
- static supplyAsync<U>(supplier: () => U): ICompletionStage<U>
115
- {
116
- return new CompletableObservable<U>(
117
- new Observable<U>(
118
- observer => observer.next(supplier())),
119
- false);
120
- }
121
-
122
- private initializeObservable(input: Observable<T>): Observable<CompletionContext<T>>
123
- {
124
- return input.pipe(map(value => CompletionContext.ofResult(value)));
125
- }
126
-
127
- private doApply<U>(context: CompletionContext<T>,func: (input: T) => U): CompletionContext<U>
128
- {
129
- console.log("doApply");
130
- if (context.hasError())
131
- return CompletionContext.ofError<U>(context.getError());
132
-
133
- try
134
- {
135
- return CompletionContext.ofResult(func(context.getResult()));
136
- }
137
- catch (e)
138
- {
139
- console.log("Caught exception in doApply");
140
- return CompletionContext.ofError<U>(new CompletionError(e));
141
- }
142
- }
143
-
144
- private doCompose<U>(
145
- func: (input: T) => ICompletionStage<U>,
146
- context: CompletionContext<T>): CompletionContext<ICompletionStage<U>>
147
- {
148
- console.log("doCompose");
149
- if (context.hasError())
150
- return CompletionContext.ofError<ICompletionStage<U>>(context.getError());
151
-
152
- try
153
- {
154
- return CompletionContext.ofResult(func(context.getResult()));
155
- }
156
- catch (e)
157
- {
158
- console.log("Caught exception in doCompose");
159
- return CompletionContext.ofError<ICompletionStage<U>>(e);
160
- }
161
- }
162
-
163
- private doAccept(
164
- context: CompletionContext<T>,
165
- consumer: (input: T) => void,
166
- handler?: (error: Error) => void): CompletionContext<T>
167
- {
168
- console.log("doAccept");
169
- if (context.hasError())
170
- {
171
- if (handler != null)
172
- {
173
- try
174
- {
175
- handler(context.getError());
176
- }
177
- catch (e)
178
- {
179
- console.log("Caught exception in doAccept");
180
- return context.setError(new CompletionError(e));
181
- }
182
- }
183
- }
184
- else
185
- {
186
- try
187
- {
188
- consumer(context.getResult());
189
- }
190
- catch (e)
191
- {
192
- return context.setError(new CompletionError(e));
193
- }
194
- }
195
-
196
- return context;
197
- }
198
-
199
- private doExceptionally(context: CompletionContext<T>,func: (error: Error) => T): CompletionContext<T>
200
- {
201
- console.log("doExceptionally");
202
- if (context.hasError())
203
- return CompletionContext.ofResult(func(context.getError()));
204
-
205
- return context;
206
- }
207
-
208
- private toObservable<U>(input: CompletionContext<ICompletionStage<U>>): Observable<CompletionContext<U>>
209
- {
210
- if (input.hasResult())
211
- return (<CompletableObservable<U>>input.getResult()).observable;
212
-
213
- return this.observable.pipe(
214
- map(
215
- (context,ignore) =>
216
- CompletionContext.ofError<U>(input.getError())))
217
- }
218
- }
@@ -1,106 +0,0 @@
1
- import {CompletionError} from "./CompletionError";
2
-
3
- export
4
- class CompletionContext<T>
5
- {
6
- private result: T;
7
- private error: CompletionError;
8
-
9
- protected constructor(result: T,error: CompletionError)
10
- {
11
- this.result = result;
12
- this.error = error;
13
- }
14
-
15
- setResult(result: T): CompletionContext<T>
16
- {
17
- this.result = result;
18
- return this;
19
- }
20
-
21
- clearResult(): CompletionContext<T>
22
- {
23
- this.result = null;
24
- return this;
25
- }
26
-
27
- setError(error: CompletionError): CompletionContext<T>
28
- {
29
- this.error = error;
30
- return this;
31
- }
32
-
33
- clearError(): CompletionContext<T>
34
- {
35
- this.error = null;
36
- return this;
37
- }
38
-
39
- getResult(): T
40
- {
41
- return this.result;
42
- }
43
-
44
- getError(): CompletionError
45
- {
46
- return this.error;
47
- }
48
-
49
- hasResult(): boolean
50
- {
51
- return this.result != null;
52
- }
53
-
54
- hasError(): boolean
55
- {
56
- return this.error != null;
57
- }
58
-
59
- combine(other: CompletionContext<T>,combiner: (x: T,y: T) => T): CompletionContext<T>
60
- {
61
- if (this.hasError() || other.hasError())
62
- {
63
- let x: CompletionError = this.getError();
64
- let y: CompletionError = other.getError();
65
-
66
- if (x != null && y != null)
67
- return new CompletionContext<T>(
68
- combiner(this.getResult(),other.getResult()),
69
- new CompletionError([x.getCause(),y.getCause()]));
70
- else if (x != null)
71
- return new CompletionContext<T>(
72
- combiner(this.getResult(),other.getResult()),
73
- x);
74
- else
75
- return new CompletionContext<T>(
76
- combiner(this.getResult(),other.getResult()),
77
- y);
78
- }
79
- else
80
- {
81
- return CompletionContext.ofResult(
82
- combiner(this.getResult(),other.getResult()));
83
- }
84
- }
85
-
86
- accept(consumer: (context: CompletionContext<T>) => void): CompletionContext<T>
87
- {
88
- consumer(this);
89
- return this;
90
- }
91
-
92
- static empty<T>(): CompletionContext<T>
93
- {
94
- return new CompletionContext<T>(null,null);
95
- }
96
-
97
- static ofResult<T>(result: T): CompletionContext<T>
98
- {
99
- return new CompletionContext<T>(result,null);
100
- }
101
-
102
- static ofError<T>(error: CompletionError): CompletionContext<T>
103
- {
104
- return new CompletionContext<T>(null,error);
105
- }
106
- }
@@ -1,17 +0,0 @@
1
- export
2
- class CompletionError
3
- extends Error
4
- {
5
- private readonly cause: any;
6
-
7
- constructor(cause: any)
8
- {
9
- super(cause instanceof Error ? cause.message : cause.toString());
10
- this.cause = cause;
11
- }
12
-
13
- getCause(): any
14
- {
15
- return this.cause;
16
- }
17
- }
@@ -1,14 +0,0 @@
1
- export
2
- interface ICompletionStage<T>
3
- {
4
- thenApply<U>(func: (input: T) => U): ICompletionStage<U>;
5
-
6
- thenCompose<U>(func: (input: T) => ICompletionStage<U>): ICompletionStage<U>;
7
-
8
- thenAccept(consumer: (result: T) => void,handler?: (error: Error) => void): ICompletionStage<T>;
9
-
10
- exceptionally(func: (error: Error) => T): ICompletionStage<T>;
11
-
12
- subscribe(consumer?: (result: T) => void,handler?: (error: Error) => void): void
13
-
14
- }
@@ -1,24 +0,0 @@
1
- export
2
- interface IMultiMap<K,V>
3
- {
4
- put(key:K,value:V): IMultiMap<K,V>;
5
-
6
- remove(key:K): IMultiMap<K,V>;
7
-
8
- remove(key: K,value: V): IMultiMap<K,V>;
9
-
10
- get(key: K): Array<V>;
11
-
12
- getAt(key: K,index: number): V;
13
-
14
- getCardinality(key: K): number;
15
-
16
- getKeys(): Array<K>;
17
-
18
- getValues(): Array<Array<V>>;
19
-
20
- containsKey(key: K): boolean;
21
-
22
- containsValue(key: K,value: V): boolean;
23
-
24
- }
@@ -1,86 +0,0 @@
1
- import {IMultiMap} from "./IMultiMap";
2
-
3
- export
4
- class MultiMap<K,V>
5
- implements IMultiMap<K,V>
6
- {
7
- private imp: Map<K,Array<V>>;
8
-
9
- constructor()
10
- {
11
- this.imp = new Map<K,Array<V>>();
12
- }
13
-
14
- put(key: K, value: V): IMultiMap<K,V>
15
- {
16
- if ( key == null )
17
- throw new Error("key is null");
18
-
19
- if ( !this.imp.has( key ))
20
- this.imp.set( key,new Array<V>() );
21
-
22
- this.imp.get( key ).push( value );
23
- return this;
24
- }
25
-
26
- remove(key: K): IMultiMap<K,V>;
27
- remove(key: K, value: V): IMultiMap<K,V>;
28
- remove(key: K, value?: V): IMultiMap<K,V>
29
- {
30
- if (value)
31
- {
32
- if ( this.imp.has( key ))
33
- {
34
- let values: Array<V> = this.imp.get(key);
35
-
36
- values.slice(values.indexOf(value),1);
37
- }
38
- }
39
- else
40
- {
41
- if (this.imp.has(key))
42
- this.imp.delete(key);
43
- }
44
-
45
- return this;
46
- }
47
-
48
- get(key: K): Array<V>
49
- {
50
- return this.imp.get(key);
51
- }
52
-
53
- getAt(key: K, index: number): V
54
- {
55
- return this.imp.get(key)[index];
56
- }
57
-
58
- getCardinality(key: K): number
59
- {
60
- return this.imp.get(key).length;
61
- }
62
-
63
- getKeys(): Array<K>
64
- {
65
- return Array.from(this.imp.keys());
66
- }
67
-
68
- getValues(): Array<Array<V>>
69
- {
70
- return Array.from(this.imp.values());
71
- }
72
-
73
- containsKey(key: K): boolean
74
- {
75
- return this.imp.has(key);
76
- }
77
-
78
- containsValue(key: K, value: V): boolean
79
- {
80
- if (this.containsKey(key))
81
- return this.get(key).includes(value);
82
-
83
- return false;
84
- }
85
-
86
- }
package/index.ts DELETED
@@ -1,7 +0,0 @@
1
- export {IMultiMap} from './Container/IMultiMap';
2
- export {MultiMap} from './Container/MultiMap';
3
-
4
- export {ICompletionStage} from './Concurrent/ICompletionStage';
5
- export {CompletableObservable} from './Concurrent/CompletableObservable';
6
- export {CompletionContext} from './Concurrent/CompletionContext';
7
- export {CompletionError} from './Concurrent/CompletionError';
Binary file
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "es2018",
5
- "sourceMap": true,
6
- "declaration": true,
7
- "outDir": "build/dist"
8
- },
9
- "include": [
10
- "**/*",
11
- "typings/**/*"
12
- ],
13
- "exclude": [
14
- "node_modules",
15
- "lib",
16
- "Strata.Client.Core.iml"
17
- ]
18
- }