@everyonesoftware/common 6.0.0 → 8.0.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.
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // sources/index.ts
31
31
  var sources_exports = {};
32
32
  __export(sources_exports, {
33
+ ANSIStyles: () => ANSIStyles,
33
34
  AsyncIterator: () => AsyncIterator,
34
35
  AsyncIteratorToJavascriptAsyncIteratorAdapter: () => AsyncIteratorToJavascriptAsyncIteratorAdapter,
35
36
  AsyncResult: () => AsyncResult,
@@ -42,6 +43,7 @@ __export(sources_exports, {
42
43
  CharacterListStream: () => CharacterListStream,
43
44
  CharacterReadStream: () => CharacterReadStream,
44
45
  CharacterReadStreamAsyncIterator: () => CharacterReadStreamAsyncIterator,
46
+ CharacterTable: () => CharacterTable,
45
47
  CharacterWriteStream: () => CharacterWriteStream,
46
48
  CommandLineParameter: () => CommandLineParameter,
47
49
  CommandLineParameters: () => CommandLineParameters,
@@ -71,6 +73,8 @@ __export(sources_exports, {
71
73
  HttpOutgoingResponse: () => HttpOutgoingResponse,
72
74
  HttpServer: () => HttpServer,
73
75
  InMemoryCharacterWriteStream: () => InMemoryCharacterWriteStream,
76
+ IndentedCharacterWriteStream: () => IndentedCharacterWriteStream,
77
+ Indexable: () => Indexable,
74
78
  Iterable: () => Iterable,
75
79
  Iterator: () => Iterator,
76
80
  IteratorToJavascriptIteratorAdapter: () => IteratorToJavascriptIteratorAdapter,
@@ -91,6 +95,7 @@ __export(sources_exports, {
91
95
  MapIterator: () => MapIterator,
92
96
  MutableCondition: () => MutableCondition,
93
97
  MutableHttpHeaders: () => MutableHttpHeaders,
98
+ MutableIndexable: () => MutableIndexable,
94
99
  MutableMap: () => MutableMap,
95
100
  Network: () => Network,
96
101
  Node: () => Node,
@@ -192,6 +197,40 @@ __export(sources_exports, {
192
197
  });
193
198
  module.exports = __toCommonJS(sources_exports);
194
199
 
200
+ // sources/ANSIStyles.ts
201
+ var ANSIStyles = class {
202
+ constructor() {
203
+ }
204
+ static color(colorCode, text) {
205
+ return `\x1B[${colorCode}m${text}\x1B[0m`;
206
+ }
207
+ static black(text) {
208
+ return this.color(30, text);
209
+ }
210
+ static red(text) {
211
+ return this.color(31, text);
212
+ }
213
+ static green(text) {
214
+ return this.color(32, text);
215
+ }
216
+ static yellow(text) {
217
+ return this.color(33, text);
218
+ }
219
+ static blue(text) {
220
+ return this.color(34, text);
221
+ }
222
+ };
223
+
224
+ // sources/CharacterTable.ts
225
+ var CharacterTable = class _CharacterTable {
226
+ constructor() {
227
+ }
228
+ static create() {
229
+ return new _CharacterTable();
230
+ }
231
+ // public getRows()
232
+ };
233
+
195
234
  // sources/bytes.ts
196
235
  var Bytes = class _Bytes {
197
236
  /**
@@ -609,109 +648,6 @@ function isPromise(value) {
609
648
  return isPromiseLike(value) && hasFunction(value, "catch", 1) && hasFunction(value, "finally", 1);
610
649
  }
611
650
 
612
- // sources/promiseAsyncResult.ts
613
- var PromiseAsyncResult = class _PromiseAsyncResult {
614
- promise;
615
- constructor(promise) {
616
- PreCondition.assertNotUndefinedAndNotNull(promise, "promise");
617
- this.promise = promise;
618
- }
619
- static create(actionOrPromise) {
620
- PreCondition.assertNotUndefinedAndNotNull(actionOrPromise, "action or promise");
621
- return new _PromiseAsyncResult(Promise.resolve(isPromise(actionOrPromise) ? actionOrPromise : actionOrPromise()));
622
- }
623
- static value(value) {
624
- return _PromiseAsyncResult.create(Promise.resolve(value));
625
- }
626
- static error(error) {
627
- return _PromiseAsyncResult.create(Promise.reject(error));
628
- }
629
- static yield() {
630
- return _PromiseAsyncResult.create(Promise.resolve());
631
- }
632
- then(onfulfilled, onrejected) {
633
- return _PromiseAsyncResult.create(this.promise.then(onfulfilled, onrejected));
634
- }
635
- onValue(onValueFunction) {
636
- return this.then(async (value) => {
637
- let result;
638
- try {
639
- await onValueFunction(value);
640
- result = this;
641
- } catch (error) {
642
- result = _PromiseAsyncResult.error(error);
643
- }
644
- return result;
645
- });
646
- }
647
- catch(errorTypeOrOnRejected, onrejected) {
648
- let errorType;
649
- if (!isUndefinedOrNull(onrejected)) {
650
- errorType = errorTypeOrOnRejected;
651
- PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
652
- } else {
653
- onrejected = errorTypeOrOnRejected;
654
- }
655
- return _PromiseAsyncResult.create(this.promise.catch((reason) => {
656
- let value;
657
- if (errorType && !instanceOfType(reason, errorType)) {
658
- throw reason;
659
- } else if (!isUndefinedOrNull(onrejected)) {
660
- value = onrejected(reason);
661
- }
662
- return value;
663
- }));
664
- }
665
- onError(errorTypeOrOnErrorFunction, onErrorFunction) {
666
- let errorType;
667
- if (!isUndefinedOrNull(onErrorFunction)) {
668
- errorType = errorTypeOrOnErrorFunction;
669
- PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
670
- } else {
671
- onErrorFunction = errorTypeOrOnErrorFunction;
672
- }
673
- PreCondition.assertNotUndefinedAndNotNull(onErrorFunction, "onErrorFunction");
674
- let result;
675
- if (errorType) {
676
- result = this.catch(errorType, async (reason) => {
677
- await onErrorFunction(reason);
678
- throw reason;
679
- });
680
- } else {
681
- result = this.catch(async (reason) => {
682
- await onErrorFunction(reason);
683
- throw reason;
684
- });
685
- }
686
- return result;
687
- }
688
- convertError(errorTypeOrConvertErrorFunction, convertErrorFunction) {
689
- let errorType;
690
- if (!isUndefinedOrNull(convertErrorFunction)) {
691
- errorType = errorTypeOrConvertErrorFunction;
692
- PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
693
- } else {
694
- convertErrorFunction = errorTypeOrConvertErrorFunction;
695
- }
696
- PreCondition.assertNotUndefinedAndNotNull(convertErrorFunction, "convertErrorFunction");
697
- let result;
698
- if (errorType) {
699
- result = this.catch(errorType, async (reason) => {
700
- throw await convertErrorFunction(reason);
701
- });
702
- } else {
703
- result = this.catch(async (reason) => {
704
- throw await convertErrorFunction(reason);
705
- });
706
- }
707
- return result;
708
- }
709
- finally(onfinally) {
710
- return _PromiseAsyncResult.create(this.promise.finally(onfinally));
711
- }
712
- [Symbol.toStringTag] = "AsyncResult";
713
- };
714
-
715
651
  // sources/syncResult.ts
716
652
  var SyncResult = class _SyncResult {
717
653
  value;
@@ -1956,6 +1892,118 @@ var Iterator = class _Iterator {
1956
1892
  }
1957
1893
  };
1958
1894
 
1895
+ // sources/Indexable.ts
1896
+ var Indexable = class _Indexable {
1897
+ static create(values) {
1898
+ return List.create(values);
1899
+ }
1900
+ toArray() {
1901
+ return _Indexable.toArray(this);
1902
+ }
1903
+ static toArray(indexable) {
1904
+ return Iterable.toArray(indexable);
1905
+ }
1906
+ any() {
1907
+ return _Indexable.any(this);
1908
+ }
1909
+ static any(indexable) {
1910
+ return Iterable.any(indexable);
1911
+ }
1912
+ getCount() {
1913
+ return _Indexable.getCount(this);
1914
+ }
1915
+ static getCount(indexable) {
1916
+ return Iterable.getCount(indexable);
1917
+ }
1918
+ equals(right, equalFunctions) {
1919
+ return _Indexable.equals(this, right, equalFunctions);
1920
+ }
1921
+ static equals(left, right, equalFunctions) {
1922
+ return Iterable.equals(left, right, equalFunctions);
1923
+ }
1924
+ toString(toStringFunctions) {
1925
+ return _Indexable.toString(this, toStringFunctions);
1926
+ }
1927
+ static toString(indexable, toStringFunctions) {
1928
+ return Iterable.toString(indexable, toStringFunctions);
1929
+ }
1930
+ concatenate(...toConcatenate) {
1931
+ return _Indexable.concatenate(this, ...toConcatenate);
1932
+ }
1933
+ static concatenate(indexable, ...toConcatenate) {
1934
+ return Iterable.concatenate(indexable, ...toConcatenate);
1935
+ }
1936
+ map(mapping) {
1937
+ return _Indexable.map(this, mapping);
1938
+ }
1939
+ static map(indexable, mapping) {
1940
+ return Iterable.map(indexable, mapping);
1941
+ }
1942
+ flatMap(mapping) {
1943
+ return _Indexable.flatMap(this, mapping);
1944
+ }
1945
+ static flatMap(indexable, mapping) {
1946
+ return Iterable.flatMap(indexable, mapping);
1947
+ }
1948
+ where(condition) {
1949
+ return _Indexable.where(this, condition);
1950
+ }
1951
+ static where(indexable, condition) {
1952
+ return Iterable.where(indexable, condition);
1953
+ }
1954
+ instanceOf(typeOrTypeCheck) {
1955
+ return _Indexable.instanceOf(this, typeOrTypeCheck);
1956
+ }
1957
+ static instanceOf(indexable, typeOrTypeCheck) {
1958
+ return Iterable.instanceOf(indexable, typeOrTypeCheck);
1959
+ }
1960
+ first(condition) {
1961
+ return _Indexable.first(this, condition);
1962
+ }
1963
+ static first(indexable, condition) {
1964
+ let result;
1965
+ if (condition) {
1966
+ result = Iterable.first(indexable, condition);
1967
+ } else {
1968
+ if (indexable.any().await()) {
1969
+ result = indexable.get(0);
1970
+ } else {
1971
+ result = SyncResult.error(new EmptyError());
1972
+ }
1973
+ }
1974
+ return result;
1975
+ }
1976
+ last(condition) {
1977
+ return _Indexable.last(this, condition);
1978
+ }
1979
+ static last(indexable, condition) {
1980
+ let result;
1981
+ if (condition) {
1982
+ result = Iterable.last(indexable, condition);
1983
+ } else {
1984
+ const count = indexable.getCount().await();
1985
+ if (count > 0) {
1986
+ result = indexable.get(count - 1);
1987
+ } else {
1988
+ result = SyncResult.error(new EmptyError());
1989
+ }
1990
+ }
1991
+ return result;
1992
+ }
1993
+ [Symbol.iterator]() {
1994
+ return _Indexable[Symbol.iterator](this);
1995
+ }
1996
+ static [Symbol.iterator](indexable) {
1997
+ return Iterable[Symbol.iterator](indexable);
1998
+ }
1999
+ contains(value, equalFunctions) {
2000
+ return _Indexable.contains(this, value, equalFunctions);
2001
+ }
2002
+ static contains(indexable, value, equalFunctions) {
2003
+ return Iterable.contains(indexable, value, equalFunctions);
2004
+ }
2005
+ };
2006
+
1959
2007
  // sources/javascriptArrayList.ts
1960
2008
  var JavascriptArrayList = class _JavascriptArrayList {
1961
2009
  array;
@@ -2057,6 +2105,97 @@ var JavascriptArrayList = class _JavascriptArrayList {
2057
2105
  }
2058
2106
  };
2059
2107
 
2108
+ // sources/MutableIndexable.ts
2109
+ var MutableIndexable = class _MutableIndexable {
2110
+ static create(values) {
2111
+ return List.create(values);
2112
+ }
2113
+ toArray() {
2114
+ return _MutableIndexable.toArray(this);
2115
+ }
2116
+ static toArray(indexable) {
2117
+ return Indexable.toArray(indexable);
2118
+ }
2119
+ any() {
2120
+ return _MutableIndexable.any(this);
2121
+ }
2122
+ static any(indexable) {
2123
+ return Indexable.any(indexable);
2124
+ }
2125
+ getCount() {
2126
+ return _MutableIndexable.getCount(this);
2127
+ }
2128
+ static getCount(indexable) {
2129
+ return Indexable.getCount(indexable);
2130
+ }
2131
+ equals(right, equalFunctions) {
2132
+ return _MutableIndexable.equals(this, right, equalFunctions);
2133
+ }
2134
+ static equals(left, right, equalFunctions) {
2135
+ return Indexable.equals(left, right, equalFunctions);
2136
+ }
2137
+ toString(toStringFunctions) {
2138
+ return _MutableIndexable.toString(this, toStringFunctions);
2139
+ }
2140
+ static toString(indexable, toStringFunctions) {
2141
+ return Indexable.toString(indexable, toStringFunctions);
2142
+ }
2143
+ concatenate(...toConcatenate) {
2144
+ return _MutableIndexable.concatenate(this, ...toConcatenate);
2145
+ }
2146
+ static concatenate(indexable, ...toConcatenate) {
2147
+ return Indexable.concatenate(indexable, ...toConcatenate);
2148
+ }
2149
+ map(mapping) {
2150
+ return _MutableIndexable.map(this, mapping);
2151
+ }
2152
+ static map(indexable, mapping) {
2153
+ return Indexable.map(indexable, mapping);
2154
+ }
2155
+ flatMap(mapping) {
2156
+ return _MutableIndexable.flatMap(this, mapping);
2157
+ }
2158
+ static flatMap(indexable, mapping) {
2159
+ return Indexable.flatMap(indexable, mapping);
2160
+ }
2161
+ where(condition) {
2162
+ return _MutableIndexable.where(this, condition);
2163
+ }
2164
+ static where(indexable, condition) {
2165
+ return Indexable.where(indexable, condition);
2166
+ }
2167
+ instanceOf(typeOrTypeCheck) {
2168
+ return _MutableIndexable.instanceOf(this, typeOrTypeCheck);
2169
+ }
2170
+ static instanceOf(indexable, typeOrTypeCheck) {
2171
+ return Indexable.instanceOf(indexable, typeOrTypeCheck);
2172
+ }
2173
+ first(condition) {
2174
+ return _MutableIndexable.first(this, condition);
2175
+ }
2176
+ static first(indexable, condition) {
2177
+ return Indexable.first(indexable, condition);
2178
+ }
2179
+ last(condition) {
2180
+ return _MutableIndexable.last(this, condition);
2181
+ }
2182
+ static last(indexable, condition) {
2183
+ return Indexable.last(indexable, condition);
2184
+ }
2185
+ [Symbol.iterator]() {
2186
+ return Indexable[Symbol.iterator](this);
2187
+ }
2188
+ static [Symbol.iterator](indexable) {
2189
+ return Iterable[Symbol.iterator](indexable);
2190
+ }
2191
+ contains(value, equalFunctions) {
2192
+ return _MutableIndexable.contains(this, value, equalFunctions);
2193
+ }
2194
+ static contains(indexable, value, equalFunctions) {
2195
+ return Indexable.contains(indexable, value, equalFunctions);
2196
+ }
2197
+ };
2198
+
2060
2199
  // sources/javascript.ts
2061
2200
  var JavascriptMap = Map;
2062
2201
  var JavascriptSet = Set;
@@ -2907,85 +3046,85 @@ var List = class _List {
2907
3046
  return _List.toArray(this);
2908
3047
  }
2909
3048
  static toArray(list2) {
2910
- return Iterable.toArray(list2);
3049
+ return MutableIndexable.toArray(list2);
2911
3050
  }
2912
3051
  any() {
2913
3052
  return _List.any(this);
2914
3053
  }
2915
3054
  static any(list2) {
2916
- return Iterable.any(list2);
3055
+ return MutableIndexable.any(list2);
2917
3056
  }
2918
3057
  getCount() {
2919
3058
  return _List.getCount(this);
2920
3059
  }
2921
3060
  static getCount(list2) {
2922
- return Iterable.getCount(list2);
3061
+ return MutableIndexable.getCount(list2);
2923
3062
  }
2924
3063
  equals(right, equalFunctions) {
2925
3064
  return _List.equals(this, right, equalFunctions);
2926
3065
  }
2927
3066
  static equals(left, right, equalFunctions) {
2928
- return Iterable.equals(left, right, equalFunctions);
3067
+ return MutableIndexable.equals(left, right, equalFunctions);
2929
3068
  }
2930
3069
  toString(toStringFunctions) {
2931
3070
  return _List.toString(this, toStringFunctions);
2932
3071
  }
2933
3072
  static toString(list2, toStringFunctions) {
2934
- return Iterable.toString(list2, toStringFunctions);
3073
+ return MutableIndexable.toString(list2, toStringFunctions);
2935
3074
  }
2936
3075
  concatenate(...toConcatenate) {
2937
3076
  return _List.concatenate(this, ...toConcatenate);
2938
3077
  }
2939
3078
  static concatenate(list2, ...toConcatenate) {
2940
- return Iterable.concatenate(list2, ...toConcatenate);
3079
+ return MutableIndexable.concatenate(list2, ...toConcatenate);
2941
3080
  }
2942
3081
  map(mapping) {
2943
3082
  return _List.map(this, mapping);
2944
3083
  }
2945
3084
  static map(list2, mapping) {
2946
- return Iterable.map(list2, mapping);
3085
+ return MutableIndexable.map(list2, mapping);
2947
3086
  }
2948
3087
  flatMap(mapping) {
2949
3088
  return _List.flatMap(this, mapping);
2950
3089
  }
2951
3090
  static flatMap(list2, mapping) {
2952
- return Iterable.flatMap(list2, mapping);
3091
+ return MutableIndexable.flatMap(list2, mapping);
2953
3092
  }
2954
3093
  where(condition) {
2955
3094
  return _List.where(this, condition);
2956
3095
  }
2957
3096
  static where(list2, condition) {
2958
- return Iterable.where(list2, condition);
3097
+ return MutableIndexable.where(list2, condition);
2959
3098
  }
2960
3099
  instanceOf(typeOrTypeCheck) {
2961
3100
  return _List.instanceOf(this, typeOrTypeCheck);
2962
3101
  }
2963
3102
  static instanceOf(list2, typeOrTypeCheck) {
2964
- return Iterable.instanceOf(list2, typeOrTypeCheck);
3103
+ return MutableIndexable.instanceOf(list2, typeOrTypeCheck);
2965
3104
  }
2966
3105
  first(condition) {
2967
3106
  return _List.first(this, condition);
2968
3107
  }
2969
3108
  static first(list2, condition) {
2970
- return condition ? Iterable.first(list2, condition) : list2.get(0);
3109
+ return MutableIndexable.first(list2, condition);
2971
3110
  }
2972
3111
  last(condition) {
2973
3112
  return _List.last(this, condition);
2974
3113
  }
2975
3114
  static last(list2, condition) {
2976
- return condition ? Iterable.last(list2, condition) : list2.get(list2.getCount().await() - 1);
3115
+ return MutableIndexable.last(list2, condition);
2977
3116
  }
2978
3117
  [Symbol.iterator]() {
2979
3118
  return _List[Symbol.iterator](this);
2980
3119
  }
2981
3120
  static [Symbol.iterator](list2) {
2982
- return Iterable[Symbol.iterator](list2);
3121
+ return Indexable[Symbol.iterator](list2);
2983
3122
  }
2984
3123
  contains(value, equalFunctions) {
2985
3124
  return _List.contains(this, value, equalFunctions);
2986
3125
  }
2987
3126
  static contains(list2, value, equalFunctions) {
2988
- return Iterable.contains(list2, value, equalFunctions);
3127
+ return MutableIndexable.contains(list2, value, equalFunctions);
2989
3128
  }
2990
3129
  };
2991
3130
 
@@ -3342,7 +3481,7 @@ var WhereIterable = class _WhereIterable {
3342
3481
  // sources/iterable.ts
3343
3482
  var Iterable = class _Iterable {
3344
3483
  static create(values) {
3345
- return List.create(values);
3484
+ return Indexable.create(values);
3346
3485
  }
3347
3486
  [Symbol.iterator]() {
3348
3487
  return _Iterable[Symbol.iterator](this);
@@ -3829,7 +3968,7 @@ var MutableCondition = class _MutableCondition {
3829
3968
  }
3830
3969
  assertNotEmpty(value, expression, message) {
3831
3970
  this.assertNotUndefinedAndNotNull(value, expression, message);
3832
- if (isString(value) && value.length === 0 || isJavascriptIterable(value) && !Iterable.create(value).any()) {
3971
+ if (isString(value) && value.length === 0 || isJavascriptIterable(value) && !Iterable.create(value).any().await()) {
3833
3972
  throw this.createError({
3834
3973
  expected: "not empty",
3835
3974
  actual: this.toValueString(value),
@@ -4195,25 +4334,528 @@ var PreCondition = class _PreCondition {
4195
4334
  }
4196
4335
  };
4197
4336
 
4198
- // sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts
4199
- var AsyncIteratorToJavascriptAsyncIteratorAdapter = class _AsyncIteratorToJavascriptAsyncIteratorAdapter {
4200
- iterator;
4201
- hasStarted;
4202
- constructor(iterator) {
4203
- PreCondition.assertNotUndefinedAndNotNull(iterator, "iterator");
4204
- this.iterator = iterator;
4205
- this.hasStarted = false;
4206
- }
4207
- static create(iterator) {
4208
- return new _AsyncIteratorToJavascriptAsyncIteratorAdapter(iterator);
4337
+ // sources/promiseAsyncResult.ts
4338
+ var PromiseAsyncResult = class _PromiseAsyncResult {
4339
+ promise;
4340
+ constructor(promise) {
4341
+ PreCondition.assertNotUndefinedAndNotNull(promise, "promise");
4342
+ this.promise = promise;
4209
4343
  }
4210
- async next() {
4211
- if (!this.hasStarted) {
4212
- this.hasStarted = true;
4213
- await this.iterator.start();
4344
+ static create(actionOrPromise) {
4345
+ PreCondition.assertNotUndefinedAndNotNull(actionOrPromise, "action or promise");
4346
+ let promise;
4347
+ if (isPromise(actionOrPromise)) {
4348
+ promise = actionOrPromise;
4214
4349
  } else {
4215
- await this.iterator.next();
4216
- }
4350
+ let actionExecutor2 = function(resolve, reject) {
4351
+ try {
4352
+ resolve(action());
4353
+ } catch (error) {
4354
+ reject(error);
4355
+ }
4356
+ };
4357
+ var actionExecutor = actionExecutor2;
4358
+ const action = actionOrPromise;
4359
+ ;
4360
+ promise = new Promise(actionExecutor2);
4361
+ }
4362
+ return new _PromiseAsyncResult(promise);
4363
+ }
4364
+ static empty() {
4365
+ return _PromiseAsyncResult.create(Promise.resolve());
4366
+ }
4367
+ static value(value) {
4368
+ return _PromiseAsyncResult.create(Promise.resolve(value));
4369
+ }
4370
+ static error(error) {
4371
+ return _PromiseAsyncResult.create(Promise.reject(error));
4372
+ }
4373
+ static yield() {
4374
+ return _PromiseAsyncResult.create(Promise.resolve());
4375
+ }
4376
+ then(onfulfilled, onrejected) {
4377
+ return _PromiseAsyncResult.create(this.promise.then(onfulfilled, onrejected));
4378
+ }
4379
+ onValue(onValueFunction) {
4380
+ return this.then(async (value) => {
4381
+ let result;
4382
+ try {
4383
+ await onValueFunction(value);
4384
+ result = this;
4385
+ } catch (error) {
4386
+ result = _PromiseAsyncResult.error(error);
4387
+ }
4388
+ return result;
4389
+ });
4390
+ }
4391
+ catch(errorTypeOrOnRejected, onrejected) {
4392
+ let errorType;
4393
+ if (!isUndefinedOrNull(onrejected)) {
4394
+ errorType = errorTypeOrOnRejected;
4395
+ PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
4396
+ } else {
4397
+ onrejected = errorTypeOrOnRejected;
4398
+ }
4399
+ return _PromiseAsyncResult.create(this.promise.catch((reason) => {
4400
+ let value;
4401
+ if (errorType && !instanceOfType(reason, errorType)) {
4402
+ throw reason;
4403
+ } else if (!isUndefinedOrNull(onrejected)) {
4404
+ value = onrejected(reason);
4405
+ }
4406
+ return value;
4407
+ }));
4408
+ }
4409
+ onError(errorTypeOrOnErrorFunction, onErrorFunction) {
4410
+ let errorType;
4411
+ if (!isUndefinedOrNull(onErrorFunction)) {
4412
+ errorType = errorTypeOrOnErrorFunction;
4413
+ PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
4414
+ } else {
4415
+ onErrorFunction = errorTypeOrOnErrorFunction;
4416
+ }
4417
+ PreCondition.assertNotUndefinedAndNotNull(onErrorFunction, "onErrorFunction");
4418
+ let result;
4419
+ if (errorType) {
4420
+ result = this.catch(errorType, async (reason) => {
4421
+ await onErrorFunction(reason);
4422
+ throw reason;
4423
+ });
4424
+ } else {
4425
+ result = this.catch(async (reason) => {
4426
+ await onErrorFunction(reason);
4427
+ throw reason;
4428
+ });
4429
+ }
4430
+ return result;
4431
+ }
4432
+ convertError(errorTypeOrConvertErrorFunction, convertErrorFunction) {
4433
+ let errorType;
4434
+ if (!isUndefinedOrNull(convertErrorFunction)) {
4435
+ errorType = errorTypeOrConvertErrorFunction;
4436
+ PreCondition.assertNotUndefinedAndNotNull(errorType, "errorType");
4437
+ } else {
4438
+ convertErrorFunction = errorTypeOrConvertErrorFunction;
4439
+ }
4440
+ PreCondition.assertNotUndefinedAndNotNull(convertErrorFunction, "convertErrorFunction");
4441
+ let result;
4442
+ if (errorType) {
4443
+ result = this.catch(errorType, async (reason) => {
4444
+ throw await convertErrorFunction(reason);
4445
+ });
4446
+ } else {
4447
+ result = this.catch(async (reason) => {
4448
+ throw await convertErrorFunction(reason);
4449
+ });
4450
+ }
4451
+ return result;
4452
+ }
4453
+ finally(onfinally) {
4454
+ return _PromiseAsyncResult.create(this.promise.finally(onfinally));
4455
+ }
4456
+ [Symbol.toStringTag] = "AsyncResult";
4457
+ };
4458
+
4459
+ // sources/asyncResult.ts
4460
+ var AsyncResult = class {
4461
+ static create(actionOrPromise) {
4462
+ return PromiseAsyncResult.create(actionOrPromise);
4463
+ }
4464
+ /**
4465
+ * Get an {@link AsyncResult} that is already completed and doesn't do anything.
4466
+ */
4467
+ static empty() {
4468
+ return PromiseAsyncResult.empty();
4469
+ }
4470
+ /**
4471
+ * Create a new {@link AsyncResult} that contains the provided value.
4472
+ * @param value The value to wrap in a {@link AsyncResult}.
4473
+ */
4474
+ static value(value) {
4475
+ return PromiseAsyncResult.value(value);
4476
+ }
4477
+ /**
4478
+ * Create a new {@link AsyncResult} that contains the provided error.
4479
+ * @param error The error to wrap in a {@link AsyncResult}.
4480
+ */
4481
+ static error(error) {
4482
+ return PromiseAsyncResult.error(error);
4483
+ }
4484
+ static yield() {
4485
+ return PromiseAsyncResult.yield();
4486
+ }
4487
+ };
4488
+
4489
+ // sources/postConditionError.ts
4490
+ var PostConditionError = class extends Error {
4491
+ constructor(...message) {
4492
+ super(join("\n", message));
4493
+ }
4494
+ };
4495
+
4496
+ // sources/postCondition.ts
4497
+ var PostCondition = class _PostCondition {
4498
+ static condition;
4499
+ static getCondition() {
4500
+ if (_PostCondition.condition === void 0) {
4501
+ _PostCondition.condition = MutableCondition.create().setCreateErrorFunction((message) => {
4502
+ return new PostConditionError(message);
4503
+ });
4504
+ }
4505
+ return _PostCondition.condition;
4506
+ }
4507
+ /**
4508
+ * Assert that the provided value is undefined.
4509
+ * @param value The value to check.
4510
+ * @param expression The name of the expression that produced the value.
4511
+ * @param message An additional message that will be included with the error.
4512
+ */
4513
+ static assertUndefined(value, expression, message) {
4514
+ return _PostCondition.getCondition().assertUndefined(value, expression, message);
4515
+ }
4516
+ /**
4517
+ * Assert that the provided value is not undefined and not null.
4518
+ * @param value The value to check.
4519
+ * @param expression The name of the expression that produced the value.
4520
+ * @param message An additional message that will be included with the error.
4521
+ */
4522
+ static assertNotUndefined(value, expression, message) {
4523
+ return _PostCondition.getCondition().assertNotUndefined(value, expression, message);
4524
+ }
4525
+ /**
4526
+ * Assert that the provided value is not undefined and not null.
4527
+ * @param value The value to check.
4528
+ * @param expression The name of the expression that produced the value.
4529
+ * @param message An additional message that will be included with the error.
4530
+ */
4531
+ static assertNotUndefinedAndNotNull(value, expression, message) {
4532
+ return _PostCondition.getCondition().assertNotUndefinedAndNotNull(value, expression, message);
4533
+ }
4534
+ /**
4535
+ * Assert that the provided value is true.
4536
+ * @param value The value to check.
4537
+ * @param expression The name of the expression that produced the value.
4538
+ * @param message An additional message that will be included with the error.
4539
+ */
4540
+ static assertTrue(value, expression, message) {
4541
+ return _PostCondition.getCondition().assertTrue(value, expression, message);
4542
+ }
4543
+ /**
4544
+ * Assert that the provided value is false.
4545
+ * @param value The value to check.
4546
+ * @param expression The name of the expression that produced the value.
4547
+ * @param message An additional message that will be included with the error.
4548
+ */
4549
+ static assertFalse(value, expression, message) {
4550
+ return _PostCondition.getCondition().assertFalse(value, expression, message);
4551
+ }
4552
+ /**
4553
+ * Assert that the provided actual value is the same as the provided expected value.
4554
+ * @param expected The expected value.
4555
+ * @param actual The actual value.
4556
+ * @param expression The expression that produced the actual value.
4557
+ * @param message An optional message that describes the scenario.
4558
+ */
4559
+ static assertSame(expected, actual, expression, message) {
4560
+ return _PostCondition.getCondition().assertSame(expected, actual, expression, message);
4561
+ }
4562
+ /**
4563
+ * Assert that the provided actual value is not the same as the provided expected value.
4564
+ * @param expected The expected value.
4565
+ * @param actual The actual value.
4566
+ * @param expression The expression that produced the actual value.
4567
+ * @param message An optional message that describes the scenario.
4568
+ */
4569
+ static assertNotSame(expected, actual, expression, message) {
4570
+ return _PostCondition.getCondition().assertNotSame(expected, actual, expression, message);
4571
+ }
4572
+ /**
4573
+ * Assert that the provided actual value is equal to the provided expected value.
4574
+ * @param expected The expected value.
4575
+ * @param actual The actual value.
4576
+ * @param expression The expression that produced the actual value.
4577
+ * @param message An optional message that describes the scenario.
4578
+ */
4579
+ static assertEqual(expected, actual, expression, message) {
4580
+ return _PostCondition.getCondition().assertEqual(expected, actual, expression, message);
4581
+ }
4582
+ /**
4583
+ * Assert that the provided actual value is not equal to the provided expected value.
4584
+ * @param notExpected The not expected value.
4585
+ * @param actual The actual value.
4586
+ * @param expression The expression that produced the actual value.
4587
+ * @param message An optional message that describes the scenario.
4588
+ */
4589
+ static assertNotEqual(notExpected, actual, expression, message) {
4590
+ return _PostCondition.getCondition().assertNotEqual(notExpected, actual, expression, message);
4591
+ }
4592
+ /**
4593
+ * Assert that the provided value is not empty.
4594
+ * @param value The value to check.
4595
+ * @param expression The expression that produced the actual value.
4596
+ * @param message An optional message that describes the scenario.
4597
+ */
4598
+ static assertNotEmpty(value, expression, message) {
4599
+ return _PostCondition.getCondition().assertNotEmpty(value, expression, message);
4600
+ }
4601
+ /**
4602
+ * Assert that the provided value is less than the provided upperBound.
4603
+ * @param value The value to check.
4604
+ * @param upperBound The upperBound that the value must be less than.
4605
+ * @param expression The expression that produced the actual value.
4606
+ * @param message An optional message that describes the scenario.
4607
+ */
4608
+ static assertLessThan(value, upperBound, expression, message) {
4609
+ return _PostCondition.getCondition().assertLessThan(value, upperBound, expression, message);
4610
+ }
4611
+ /**
4612
+ * Assert that the provided value is less than or equal to the provided upperBound.
4613
+ * @param value The value to check.
4614
+ * @param upperBound The upperBound that the value must be less than.
4615
+ * @param expression The expression that produced the actual value.
4616
+ * @param message An optional message that describes the scenario.
4617
+ */
4618
+ static assertLessThanOrEqualTo(value, upperBound, expression, message) {
4619
+ return _PostCondition.getCondition().assertLessThanOrEqualTo(value, upperBound, expression, message);
4620
+ }
4621
+ /**
4622
+ * Assert that the provided value is greater than or equal to the provided lowerBound.
4623
+ * @param value The value to check.
4624
+ * @param lowerBound The lowerBound that the value must be greater than or equal to.
4625
+ * @param expression The expression that produced the actual value.
4626
+ * @param message An optional message that describes the scenario.
4627
+ */
4628
+ static assertGreaterThanOrEqualTo(value, lowerBound, expression, message) {
4629
+ return _PostCondition.getCondition().assertGreaterThanOrEqualTo(value, lowerBound, expression, message);
4630
+ }
4631
+ /**
4632
+ * Assert that the provided value is greater than the provided lowerBound.
4633
+ * @param value The value to check.
4634
+ * @param lowerBound The lowerBound that the value must be greater than.
4635
+ * @param expression The expression that produced the actual value.
4636
+ * @param message An optional message that describes the scenario.
4637
+ */
4638
+ static assertGreaterThan(value, lowerBound, expression, message) {
4639
+ return _PostCondition.getCondition().assertGreaterThan(value, lowerBound, expression, message);
4640
+ }
4641
+ /**
4642
+ * Assert that the value is greater than or equal to the lowerBound and less than or equal to
4643
+ * the upperBound.
4644
+ * @param lowerBound The lowerBound that the value must be greater than or equal to.
4645
+ * @param value The value to check.
4646
+ * @param upperBound The upperBound that the value must be less than or equal to.
4647
+ * @param expression The expression that produced the actual value.
4648
+ * @param message An optional message that describes the scenario.
4649
+ */
4650
+ static assertBetween(lowerBound, value, upperBound, expression, message) {
4651
+ return _PostCondition.getCondition().assertBetween(lowerBound, value, upperBound, expression, message);
4652
+ }
4653
+ /**
4654
+ * Assert that the index is within the access bounds of an indexable with the provided count.
4655
+ * @param index The index to check.
4656
+ * @param count The number of elements in the indexable.
4657
+ * @param expression The expression that produced the actual value.
4658
+ * @param message An optional message that describes the scenario.
4659
+ */
4660
+ static assertAccessIndex(index, count, expression, message) {
4661
+ return _PostCondition.getCondition().assertAccessIndex(index, count, expression, message);
4662
+ }
4663
+ /**
4664
+ * Assert that the index is within the insertion bounds of a {@link List} with the provided count.
4665
+ * @param index The index to check.
4666
+ * @param count The number of elements in the indexable.
4667
+ * @param expression The expression that produced the actual value.
4668
+ * @param message An optional message that describes the scenario.
4669
+ */
4670
+ static assertInsertIndex(index, count, expression, message) {
4671
+ return _PostCondition.getCondition().assertInsertIndex(index, count, expression, message);
4672
+ }
4673
+ /**
4674
+ * Assert that the value is one of the possibilities.
4675
+ * @param possibilities The possible values that the value can be.
4676
+ * @param value The value to check.
4677
+ * @param expression The expression that produced the value.
4678
+ * @param message An optional error message.
4679
+ */
4680
+ static assertOneOf(possibilities, value, expression, message) {
4681
+ return _PostCondition.getCondition().assertOneOf(possibilities, value, expression, message);
4682
+ }
4683
+ /**
4684
+ * Assert that the value is within the bounds of a byte.
4685
+ * @param value The value to check.
4686
+ * @param expression The expression that produced the value.
4687
+ * @param message An optional error message.
4688
+ */
4689
+ static assertByte(value, expression, message) {
4690
+ return _PostCondition.getCondition().assertByte(value, expression, message);
4691
+ }
4692
+ /**
4693
+ * Assert that the value is an integer.
4694
+ * @param value The value to check.
4695
+ * @param expression The expression that produced the value.
4696
+ * @param message An optional error message.
4697
+ */
4698
+ static assertInteger(value, expression, message) {
4699
+ return _PostCondition.getCondition().assertInteger(value, expression, message);
4700
+ }
4701
+ /**
4702
+ * Assert that the value is a characer (single character string).
4703
+ * @param value The value to check.
4704
+ * @param expression The expression that produced the value.
4705
+ * @param message An optional error message.
4706
+ */
4707
+ static assertCharacter(value, expression, message) {
4708
+ return _PostCondition.getCondition().assertCharacter(value, expression, message);
4709
+ }
4710
+ assertInstanceOf(parametersOrValue, type, typeCheck, expression, message) {
4711
+ return _PostCondition.getCondition().assertInstanceOf(parametersOrValue, type, typeCheck, expression, message);
4712
+ }
4713
+ };
4714
+
4715
+ // sources/characterWriteStream.ts
4716
+ var CharacterWriteStream = class _CharacterWriteStream {
4717
+ /**
4718
+ * Write the provided text (if provided) and then write a newline character sequence to this
4719
+ * {@link CharacterWriteStream}.
4720
+ * @param text The optional text to write before the newline character sequence.
4721
+ * @returns The number of characters that were written.
4722
+ */
4723
+ writeLine(text) {
4724
+ return _CharacterWriteStream.writeLine(this, text);
4725
+ }
4726
+ static writeLine(writeStream, text) {
4727
+ PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
4728
+ return PromiseAsyncResult.create(async () => {
4729
+ let result = 0;
4730
+ if (text) {
4731
+ result += await writeStream.writeString(text);
4732
+ }
4733
+ result += await writeStream.writeString("\n");
4734
+ PostCondition.assertGreaterThan(result, 0, "result");
4735
+ return result;
4736
+ });
4737
+ }
4738
+ };
4739
+
4740
+ // sources/IndentedCharacterWriteStream.ts
4741
+ var IndentedCharacterWriteStream = class _IndentedCharacterWriteStream extends CharacterWriteStream {
4742
+ innerStream;
4743
+ currentIndentationList;
4744
+ currentIndentation;
4745
+ singleIndent;
4746
+ atLineStart;
4747
+ constructor(innerStream) {
4748
+ PreCondition.assertNotUndefinedAndNotNull(innerStream, "innerStream");
4749
+ super();
4750
+ this.innerStream = innerStream;
4751
+ this.currentIndentationList = List.create();
4752
+ this.currentIndentation = "";
4753
+ this.singleIndent = " ";
4754
+ this.atLineStart = true;
4755
+ }
4756
+ static create(innerStream) {
4757
+ return new _IndentedCharacterWriteStream(innerStream);
4758
+ }
4759
+ getSingleIndent() {
4760
+ return this.singleIndent;
4761
+ }
4762
+ setSingleIndent(singleIndent) {
4763
+ PreCondition.assertNotUndefinedAndNotNull(singleIndent, "singleIndent");
4764
+ this.singleIndent = singleIndent;
4765
+ return this;
4766
+ }
4767
+ getCurrentIndentationCount() {
4768
+ return this.currentIndentationList.getCount().await();
4769
+ }
4770
+ getCurrentIndentation() {
4771
+ return this.currentIndentation;
4772
+ }
4773
+ addIndentation(singleIndent) {
4774
+ if (isUndefinedOrNull(singleIndent)) {
4775
+ singleIndent = this.singleIndent;
4776
+ }
4777
+ this.currentIndentationList.add(singleIndent);
4778
+ if (singleIndent) {
4779
+ this.currentIndentation = this.currentIndentation + singleIndent;
4780
+ }
4781
+ return this;
4782
+ }
4783
+ removeIndentation() {
4784
+ PreCondition.assertGreaterThanOrEqualTo(this.getCurrentIndentationCount(), 1, "this.getCurrentIndentationCount()");
4785
+ const result = this.currentIndentationList.removeLast().await();
4786
+ if (result) {
4787
+ this.currentIndentation = this.currentIndentation.substring(0, this.currentIndentation.length - result.length);
4788
+ }
4789
+ return result;
4790
+ }
4791
+ indent(actionOrSingleIndent, action) {
4792
+ let singleIndent;
4793
+ if (isString(actionOrSingleIndent)) {
4794
+ singleIndent = actionOrSingleIndent;
4795
+ action = action;
4796
+ } else {
4797
+ action = actionOrSingleIndent;
4798
+ }
4799
+ PreCondition.assertNotUndefinedAndNotNull(action, "action");
4800
+ return AsyncResult.create(async () => {
4801
+ let result;
4802
+ this.addIndentation(singleIndent);
4803
+ try {
4804
+ result = await action();
4805
+ if (!isNumber(result)) {
4806
+ result = 0;
4807
+ }
4808
+ } finally {
4809
+ this.removeIndentation();
4810
+ }
4811
+ return result;
4812
+ });
4813
+ }
4814
+ writeString(text) {
4815
+ return AsyncResult.create(async () => {
4816
+ let result = 0;
4817
+ const textLength = text.length;
4818
+ let startIndex = 0;
4819
+ while (startIndex < textLength) {
4820
+ const newLineCharacterIndex = text.indexOf("\n", startIndex);
4821
+ const atLineStartAfterWrite = newLineCharacterIndex !== -1;
4822
+ const nextLineStartIndex = atLineStartAfterWrite ? newLineCharacterIndex + 1 : textLength;
4823
+ if (newLineCharacterIndex === startIndex || newLineCharacterIndex === startIndex + 1 && text[startIndex] === "\r") {
4824
+ result += await this.innerStream.writeString(text.substring(startIndex, nextLineStartIndex));
4825
+ startIndex = nextLineStartIndex;
4826
+ } else {
4827
+ if (this.atLineStart && this.currentIndentation) {
4828
+ result += await this.innerStream.writeString(this.currentIndentation);
4829
+ }
4830
+ result += await this.innerStream.writeString(text.substring(startIndex, nextLineStartIndex));
4831
+ startIndex = nextLineStartIndex;
4832
+ }
4833
+ this.atLineStart = atLineStartAfterWrite;
4834
+ }
4835
+ return result;
4836
+ });
4837
+ }
4838
+ };
4839
+
4840
+ // sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts
4841
+ var AsyncIteratorToJavascriptAsyncIteratorAdapter = class _AsyncIteratorToJavascriptAsyncIteratorAdapter {
4842
+ iterator;
4843
+ hasStarted;
4844
+ constructor(iterator) {
4845
+ PreCondition.assertNotUndefinedAndNotNull(iterator, "iterator");
4846
+ this.iterator = iterator;
4847
+ this.hasStarted = false;
4848
+ }
4849
+ static create(iterator) {
4850
+ return new _AsyncIteratorToJavascriptAsyncIteratorAdapter(iterator);
4851
+ }
4852
+ async next() {
4853
+ if (!this.hasStarted) {
4854
+ this.hasStarted = true;
4855
+ await this.iterator.start();
4856
+ } else {
4857
+ await this.iterator.next();
4858
+ }
4217
4859
  const result = {
4218
4860
  done: !this.iterator.hasCurrent(),
4219
4861
  value: void 0
@@ -4925,30 +5567,6 @@ var AsyncIterator = class _AsyncIterator {
4925
5567
  }
4926
5568
  };
4927
5569
 
4928
- // sources/asyncResult.ts
4929
- var AsyncResult = class {
4930
- static create(actionOrPromise) {
4931
- return PromiseAsyncResult.create(isPromise(actionOrPromise) ? actionOrPromise : new Promise(actionOrPromise));
4932
- }
4933
- /**
4934
- * Create a new {@link AsyncResult} that contains the provided value.
4935
- * @param value The value to wrap in a {@link AsyncResult}.
4936
- */
4937
- static value(value) {
4938
- return PromiseAsyncResult.value(value);
4939
- }
4940
- /**
4941
- * Create a new {@link AsyncResult} that contains the provided error.
4942
- * @param error The error to wrap in a {@link AsyncResult}.
4943
- */
4944
- static error(error) {
4945
- return PromiseAsyncResult.error(error);
4946
- }
4947
- static yield() {
4948
- return PromiseAsyncResult.yield();
4949
- }
4950
- };
4951
-
4952
5570
  // sources/basicDisposable.ts
4953
5571
  var SyncDisposable = class _SyncDisposable {
4954
5572
  disposedFunction;
@@ -5372,315 +5990,64 @@ var CharacterList = class _CharacterList {
5372
5990
  first(condition) {
5373
5991
  return List.first(this, condition);
5374
5992
  }
5375
- last(condition) {
5376
- return List.last(this, condition);
5377
- }
5378
- contains(value, equalFunctions) {
5379
- return List.contains(this, value, equalFunctions);
5380
- }
5381
- [Symbol.iterator]() {
5382
- return List[Symbol.iterator](this);
5383
- }
5384
- };
5385
-
5386
- // sources/characterReadStream.ts
5387
- var CharacterReadStream = class _CharacterReadStream {
5388
- readCharacters(count) {
5389
- return _CharacterReadStream.readCharacters(this, count);
5390
- }
5391
- static readCharacters(readStream, count) {
5392
- let characters = "";
5393
- function readUntilCount(countRemaining) {
5394
- return readStream.readCharacter().then((character) => {
5395
- characters += character;
5396
- return countRemaining === 0 ? SyncResult.value(characters) : readUntilCount(countRemaining - 1);
5397
- });
5398
- }
5399
- return readUntilCount(count);
5400
- }
5401
- /**
5402
- * Read characters from this stream until the provided {@link searchString} is found or the end
5403
- * of the stream is reached. The {@link searchString} will be included in the returned string if
5404
- * it is found..
5405
- * @param searchString The string to search for.
5406
- */
5407
- readUntil(searchString) {
5408
- return _CharacterReadStream.readUntil(this, searchString);
5409
- }
5410
- static readUntil(readStream, searchString) {
5411
- PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
5412
- PreCondition.assertNotEmpty(searchString, "searchString");
5413
- let characters = "";
5414
- function readUntilSearchString() {
5415
- return readStream.readCharacter().then((character) => {
5416
- characters += character;
5417
- return characters.endsWith(searchString) ? SyncResult.value(characters) : readUntilSearchString();
5418
- });
5419
- }
5420
- return readUntilSearchString();
5421
- }
5422
- /**
5423
- * Read a sequence of characters from this stream until either a newline character ('\\n') or
5424
- * the end of the stream is reached. Terminating newline characters will be included in the
5425
- * returned string.
5426
- */
5427
- readLine() {
5428
- return _CharacterReadStream.readLine(this);
5429
- }
5430
- static readLine(readStream) {
5431
- PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
5432
- return readStream.readUntil("\n");
5433
- }
5434
- };
5435
-
5436
- // sources/postConditionError.ts
5437
- var PostConditionError = class extends Error {
5438
- constructor(...message) {
5439
- super(join("\n", message));
5440
- }
5441
- };
5442
-
5443
- // sources/postCondition.ts
5444
- var PostCondition = class _PostCondition {
5445
- static condition;
5446
- static getCondition() {
5447
- if (_PostCondition.condition === void 0) {
5448
- _PostCondition.condition = MutableCondition.create().setCreateErrorFunction((message) => {
5449
- return new PostConditionError(message);
5450
- });
5451
- }
5452
- return _PostCondition.condition;
5453
- }
5454
- /**
5455
- * Assert that the provided value is undefined.
5456
- * @param value The value to check.
5457
- * @param expression The name of the expression that produced the value.
5458
- * @param message An additional message that will be included with the error.
5459
- */
5460
- static assertUndefined(value, expression, message) {
5461
- return _PostCondition.getCondition().assertUndefined(value, expression, message);
5462
- }
5463
- /**
5464
- * Assert that the provided value is not undefined and not null.
5465
- * @param value The value to check.
5466
- * @param expression The name of the expression that produced the value.
5467
- * @param message An additional message that will be included with the error.
5468
- */
5469
- static assertNotUndefined(value, expression, message) {
5470
- return _PostCondition.getCondition().assertNotUndefined(value, expression, message);
5471
- }
5472
- /**
5473
- * Assert that the provided value is not undefined and not null.
5474
- * @param value The value to check.
5475
- * @param expression The name of the expression that produced the value.
5476
- * @param message An additional message that will be included with the error.
5477
- */
5478
- static assertNotUndefinedAndNotNull(value, expression, message) {
5479
- return _PostCondition.getCondition().assertNotUndefinedAndNotNull(value, expression, message);
5480
- }
5481
- /**
5482
- * Assert that the provided value is true.
5483
- * @param value The value to check.
5484
- * @param expression The name of the expression that produced the value.
5485
- * @param message An additional message that will be included with the error.
5486
- */
5487
- static assertTrue(value, expression, message) {
5488
- return _PostCondition.getCondition().assertTrue(value, expression, message);
5489
- }
5490
- /**
5491
- * Assert that the provided value is false.
5492
- * @param value The value to check.
5493
- * @param expression The name of the expression that produced the value.
5494
- * @param message An additional message that will be included with the error.
5495
- */
5496
- static assertFalse(value, expression, message) {
5497
- return _PostCondition.getCondition().assertFalse(value, expression, message);
5498
- }
5499
- /**
5500
- * Assert that the provided actual value is the same as the provided expected value.
5501
- * @param expected The expected value.
5502
- * @param actual The actual value.
5503
- * @param expression The expression that produced the actual value.
5504
- * @param message An optional message that describes the scenario.
5505
- */
5506
- static assertSame(expected, actual, expression, message) {
5507
- return _PostCondition.getCondition().assertSame(expected, actual, expression, message);
5508
- }
5509
- /**
5510
- * Assert that the provided actual value is not the same as the provided expected value.
5511
- * @param expected The expected value.
5512
- * @param actual The actual value.
5513
- * @param expression The expression that produced the actual value.
5514
- * @param message An optional message that describes the scenario.
5515
- */
5516
- static assertNotSame(expected, actual, expression, message) {
5517
- return _PostCondition.getCondition().assertNotSame(expected, actual, expression, message);
5518
- }
5519
- /**
5520
- * Assert that the provided actual value is equal to the provided expected value.
5521
- * @param expected The expected value.
5522
- * @param actual The actual value.
5523
- * @param expression The expression that produced the actual value.
5524
- * @param message An optional message that describes the scenario.
5525
- */
5526
- static assertEqual(expected, actual, expression, message) {
5527
- return _PostCondition.getCondition().assertEqual(expected, actual, expression, message);
5528
- }
5529
- /**
5530
- * Assert that the provided actual value is not equal to the provided expected value.
5531
- * @param notExpected The not expected value.
5532
- * @param actual The actual value.
5533
- * @param expression The expression that produced the actual value.
5534
- * @param message An optional message that describes the scenario.
5535
- */
5536
- static assertNotEqual(notExpected, actual, expression, message) {
5537
- return _PostCondition.getCondition().assertNotEqual(notExpected, actual, expression, message);
5538
- }
5539
- /**
5540
- * Assert that the provided value is not empty.
5541
- * @param value The value to check.
5542
- * @param expression The expression that produced the actual value.
5543
- * @param message An optional message that describes the scenario.
5544
- */
5545
- static assertNotEmpty(value, expression, message) {
5546
- return _PostCondition.getCondition().assertNotEmpty(value, expression, message);
5547
- }
5548
- /**
5549
- * Assert that the provided value is less than the provided upperBound.
5550
- * @param value The value to check.
5551
- * @param upperBound The upperBound that the value must be less than.
5552
- * @param expression The expression that produced the actual value.
5553
- * @param message An optional message that describes the scenario.
5554
- */
5555
- static assertLessThan(value, upperBound, expression, message) {
5556
- return _PostCondition.getCondition().assertLessThan(value, upperBound, expression, message);
5557
- }
5558
- /**
5559
- * Assert that the provided value is less than or equal to the provided upperBound.
5560
- * @param value The value to check.
5561
- * @param upperBound The upperBound that the value must be less than.
5562
- * @param expression The expression that produced the actual value.
5563
- * @param message An optional message that describes the scenario.
5564
- */
5565
- static assertLessThanOrEqualTo(value, upperBound, expression, message) {
5566
- return _PostCondition.getCondition().assertLessThanOrEqualTo(value, upperBound, expression, message);
5567
- }
5568
- /**
5569
- * Assert that the provided value is greater than or equal to the provided lowerBound.
5570
- * @param value The value to check.
5571
- * @param lowerBound The lowerBound that the value must be greater than or equal to.
5572
- * @param expression The expression that produced the actual value.
5573
- * @param message An optional message that describes the scenario.
5574
- */
5575
- static assertGreaterThanOrEqualTo(value, lowerBound, expression, message) {
5576
- return _PostCondition.getCondition().assertGreaterThanOrEqualTo(value, lowerBound, expression, message);
5577
- }
5578
- /**
5579
- * Assert that the provided value is greater than the provided lowerBound.
5580
- * @param value The value to check.
5581
- * @param lowerBound The lowerBound that the value must be greater than.
5582
- * @param expression The expression that produced the actual value.
5583
- * @param message An optional message that describes the scenario.
5584
- */
5585
- static assertGreaterThan(value, lowerBound, expression, message) {
5586
- return _PostCondition.getCondition().assertGreaterThan(value, lowerBound, expression, message);
5587
- }
5588
- /**
5589
- * Assert that the value is greater than or equal to the lowerBound and less than or equal to
5590
- * the upperBound.
5591
- * @param lowerBound The lowerBound that the value must be greater than or equal to.
5592
- * @param value The value to check.
5593
- * @param upperBound The upperBound that the value must be less than or equal to.
5594
- * @param expression The expression that produced the actual value.
5595
- * @param message An optional message that describes the scenario.
5596
- */
5597
- static assertBetween(lowerBound, value, upperBound, expression, message) {
5598
- return _PostCondition.getCondition().assertBetween(lowerBound, value, upperBound, expression, message);
5599
- }
5600
- /**
5601
- * Assert that the index is within the access bounds of an indexable with the provided count.
5602
- * @param index The index to check.
5603
- * @param count The number of elements in the indexable.
5604
- * @param expression The expression that produced the actual value.
5605
- * @param message An optional message that describes the scenario.
5606
- */
5607
- static assertAccessIndex(index, count, expression, message) {
5608
- return _PostCondition.getCondition().assertAccessIndex(index, count, expression, message);
5993
+ last(condition) {
5994
+ return List.last(this, condition);
5609
5995
  }
5610
- /**
5611
- * Assert that the index is within the insertion bounds of a {@link List} with the provided count.
5612
- * @param index The index to check.
5613
- * @param count The number of elements in the indexable.
5614
- * @param expression The expression that produced the actual value.
5615
- * @param message An optional message that describes the scenario.
5616
- */
5617
- static assertInsertIndex(index, count, expression, message) {
5618
- return _PostCondition.getCondition().assertInsertIndex(index, count, expression, message);
5996
+ contains(value, equalFunctions) {
5997
+ return List.contains(this, value, equalFunctions);
5619
5998
  }
5620
- /**
5621
- * Assert that the value is one of the possibilities.
5622
- * @param possibilities The possible values that the value can be.
5623
- * @param value The value to check.
5624
- * @param expression The expression that produced the value.
5625
- * @param message An optional error message.
5626
- */
5627
- static assertOneOf(possibilities, value, expression, message) {
5628
- return _PostCondition.getCondition().assertOneOf(possibilities, value, expression, message);
5999
+ [Symbol.iterator]() {
6000
+ return List[Symbol.iterator](this);
5629
6001
  }
5630
- /**
5631
- * Assert that the value is within the bounds of a byte.
5632
- * @param value The value to check.
5633
- * @param expression The expression that produced the value.
5634
- * @param message An optional error message.
5635
- */
5636
- static assertByte(value, expression, message) {
5637
- return _PostCondition.getCondition().assertByte(value, expression, message);
6002
+ };
6003
+
6004
+ // sources/characterReadStream.ts
6005
+ var CharacterReadStream = class _CharacterReadStream {
6006
+ readCharacters(count) {
6007
+ return _CharacterReadStream.readCharacters(this, count);
5638
6008
  }
5639
- /**
5640
- * Assert that the value is an integer.
5641
- * @param value The value to check.
5642
- * @param expression The expression that produced the value.
5643
- * @param message An optional error message.
5644
- */
5645
- static assertInteger(value, expression, message) {
5646
- return _PostCondition.getCondition().assertInteger(value, expression, message);
6009
+ static readCharacters(readStream, count) {
6010
+ let characters = "";
6011
+ function readUntilCount(countRemaining) {
6012
+ return readStream.readCharacter().then((character) => {
6013
+ characters += character;
6014
+ return countRemaining === 0 ? SyncResult.value(characters) : readUntilCount(countRemaining - 1);
6015
+ });
6016
+ }
6017
+ return readUntilCount(count);
5647
6018
  }
5648
6019
  /**
5649
- * Assert that the value is a characer (single character string).
5650
- * @param value The value to check.
5651
- * @param expression The expression that produced the value.
5652
- * @param message An optional error message.
6020
+ * Read characters from this stream until the provided {@link searchString} is found or the end
6021
+ * of the stream is reached. The {@link searchString} will be included in the returned string if
6022
+ * it is found..
6023
+ * @param searchString The string to search for.
5653
6024
  */
5654
- static assertCharacter(value, expression, message) {
5655
- return _PostCondition.getCondition().assertCharacter(value, expression, message);
6025
+ readUntil(searchString) {
6026
+ return _CharacterReadStream.readUntil(this, searchString);
5656
6027
  }
5657
- assertInstanceOf(parametersOrValue, type, typeCheck, expression, message) {
5658
- return _PostCondition.getCondition().assertInstanceOf(parametersOrValue, type, typeCheck, expression, message);
6028
+ static readUntil(readStream, searchString) {
6029
+ PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
6030
+ PreCondition.assertNotEmpty(searchString, "searchString");
6031
+ let characters = "";
6032
+ function readUntilSearchString() {
6033
+ return readStream.readCharacter().then((character) => {
6034
+ characters += character;
6035
+ return characters.endsWith(searchString) ? SyncResult.value(characters) : readUntilSearchString();
6036
+ });
6037
+ }
6038
+ return readUntilSearchString();
5659
6039
  }
5660
- };
5661
-
5662
- // sources/characterWriteStream.ts
5663
- var CharacterWriteStream = class _CharacterWriteStream {
5664
6040
  /**
5665
- * Write the provided text (if provided) and then write a newline character sequence to this
5666
- * {@link CharacterWriteStream}.
5667
- * @param text The optional text to write before the newline character sequence.
5668
- * @returns The number of characters that were written.
6041
+ * Read a sequence of characters from this stream until either a newline character ('\\n') or
6042
+ * the end of the stream is reached. Terminating newline characters will be included in the
6043
+ * returned string.
5669
6044
  */
5670
- writeLine(text) {
5671
- return _CharacterWriteStream.writeLine(this, text);
6045
+ readLine() {
6046
+ return _CharacterReadStream.readLine(this);
5672
6047
  }
5673
- static writeLine(writeStream, text) {
5674
- PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
5675
- return PromiseAsyncResult.create(async () => {
5676
- let result = 0;
5677
- if (text) {
5678
- result += await writeStream.writeString(text);
5679
- }
5680
- result += await writeStream.writeString("\n");
5681
- PostCondition.assertGreaterThan(result, 0, "result");
5682
- return result;
5683
- });
6048
+ static readLine(readStream) {
6049
+ PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
6050
+ return readStream.readUntil("\n");
5684
6051
  }
5685
6052
  };
5686
6053
 
@@ -5846,51 +6213,166 @@ var CharacterReadStreamAsyncIterator = class _CharacterReadStreamAsyncIterator {
5846
6213
  }
5847
6214
  };
5848
6215
 
5849
- // sources/commandLineParameter.ts
5850
- var CommandLineParameter = class _CommandLineParameter {
6216
+ // sources/english.ts
6217
+ function andList(values) {
6218
+ return list("and", values);
6219
+ }
6220
+ function orList(values) {
6221
+ return list("or", values);
6222
+ }
6223
+ function list(conjunction, values) {
6224
+ PreCondition.assertNotEmpty(conjunction, "conjunction");
6225
+ PreCondition.assertNotUndefinedAndNotNull(values, "values");
6226
+ let result = "";
6227
+ let index = 0;
6228
+ const iterator = Iterator.create(values).start().await();
6229
+ while (iterator.hasCurrent()) {
6230
+ const currentValue = iterator.takeCurrent().await();
6231
+ if (index >= 1) {
6232
+ if (iterator.hasCurrent()) {
6233
+ result += `, `;
6234
+ } else {
6235
+ if (index >= 2) {
6236
+ result += `,`;
6237
+ }
6238
+ result += ` ${conjunction} `;
6239
+ }
6240
+ }
6241
+ result += currentValue;
6242
+ index++;
6243
+ }
6244
+ return result;
6245
+ }
6246
+
6247
+ // sources/commandLineParameters.ts
6248
+ var CommandLineParameters = class _CommandLineParameters {
6249
+ args;
6250
+ parameters;
6251
+ constructor(argv) {
6252
+ PreCondition.assertNotUndefinedAndNotNull(argv, "argv");
6253
+ this.args = isIterable(argv) ? argv : Iterable.create(argv);
6254
+ this.parameters = List.create();
6255
+ }
6256
+ static create(args) {
6257
+ return new _CommandLineParameters(args);
6258
+ }
6259
+ static getArgumentName(arg) {
6260
+ return arg[0] === "-" ? arg.substring(arg[1] === "-" ? 2 : 1) : void 0;
6261
+ }
6262
+ getArguments() {
6263
+ return this.args;
6264
+ }
5851
6265
  /**
5852
- * The full name of this {@link CommandLineParameter}.
6266
+ * Get the value of the first argument that matches one of the provided names.
6267
+ * @param names The possible names to look for.
5853
6268
  */
6269
+ getNamedArgumentStringValue(nameOrNames) {
6270
+ PreCondition.assertNotEmpty(nameOrNames, "nameOrNames");
6271
+ return SyncResult.create(() => {
6272
+ let foundArgName = false;
6273
+ let result;
6274
+ if (isString(nameOrNames)) {
6275
+ nameOrNames = [nameOrNames];
6276
+ }
6277
+ const searchNames = Iterable.create(nameOrNames);
6278
+ for (const arg of this.args) {
6279
+ if (!foundArgName) {
6280
+ const argName = _CommandLineParameters.getArgumentName(arg);
6281
+ foundArgName = !!(argName && searchNames.contains(argName));
6282
+ } else {
6283
+ result = arg;
6284
+ break;
6285
+ }
6286
+ }
6287
+ if (result === void 0) {
6288
+ const toStringFunctions = ToStringFunctions.create();
6289
+ throw new NotFoundError(`No argument found that matches ${orList(searchNames.map((n) => toStringFunctions.toString(n)))}.`);
6290
+ }
6291
+ return result;
6292
+ });
6293
+ }
6294
+ nameOrAliasExists(nameOrAlias) {
6295
+ PreCondition.assertNotEmpty(nameOrAlias, "nameOrAlias");
6296
+ let result = false;
6297
+ for (const parameter of this.parameters) {
6298
+ if (parameter.getNameAndAliases().contains(nameOrAlias).await()) {
6299
+ result = true;
6300
+ break;
6301
+ }
6302
+ }
6303
+ return result;
6304
+ }
6305
+ add(name) {
6306
+ const result = CommandLineParameter.create({
6307
+ owner: this,
6308
+ name
6309
+ });
6310
+ this.parameters.add(result);
6311
+ return result;
6312
+ }
6313
+ };
6314
+
6315
+ // sources/commandLineParameter.ts
6316
+ var CommandLineParameter = class _CommandLineParameter {
6317
+ owner;
5854
6318
  name;
5855
- /**
5856
- * The description for this {@link CommandLineParameter}.
5857
- */
6319
+ aliases;
5858
6320
  description;
5859
- /**
5860
- * The function that can be invoked to get this {@link CommandLineParameter}'s value.
5861
- */
5862
- valueGetter;
5863
- constructor(name, description, valueGetter) {
6321
+ constructor(owner, name) {
6322
+ PreCondition.assertNotUndefinedAndNotNull(owner, "owner");
6323
+ PreCondition.assertNotEmpty(name, "name");
6324
+ PreCondition.assertFalse(owner.nameOrAliasExists(name), "owner.nameOrAliasExists(name)");
6325
+ this.owner = owner;
5864
6326
  this.name = name;
5865
- this.description = description;
5866
- this.valueGetter = valueGetter;
5867
6327
  }
5868
- /**
5869
- * Create a new {@link CommandLineParameter}.
5870
- * @param name The full name of the {@link CommandLineParameter}.
5871
- * @param description The description for the {@link CommandLineParameter}.
5872
- * @param valueGetter The function that will be used to get the returned
5873
- * {@link CommandLineParameter}'s value.
5874
- */
5875
- static create(name, description, valueGetter) {
5876
- return new _CommandLineParameter(name, description, valueGetter);
6328
+ static create(ownerOrProperties, name) {
6329
+ let owner;
6330
+ if (ownerOrProperties instanceof CommandLineParameters) {
6331
+ owner = ownerOrProperties;
6332
+ name = name;
6333
+ } else {
6334
+ owner = ownerOrProperties.owner;
6335
+ name = ownerOrProperties.name;
6336
+ }
6337
+ return new _CommandLineParameter(owner, name);
5877
6338
  }
5878
6339
  /**
5879
- * Get the value for this {@link CommandLineParameter}.
6340
+ * Get the name of this {@link CommandLineParameter}.
5880
6341
  */
5881
- getValue() {
5882
- return this.valueGetter();
6342
+ getName() {
6343
+ return this.name;
5883
6344
  }
5884
- };
5885
-
5886
- // sources/commandLineParameters.ts
5887
- var CommandLineParameters = class _CommandLineParameters {
5888
- args;
5889
- constructor(argv) {
5890
- this.args = argv;
6345
+ getAliases() {
6346
+ return this.aliases ?? Iterable.create();
5891
6347
  }
5892
- static create(args) {
5893
- return new _CommandLineParameters(args);
6348
+ nameOrAliasExists(nameOrAlias) {
6349
+ return this.owner.nameOrAliasExists(nameOrAlias);
6350
+ }
6351
+ addAlias(alias) {
6352
+ PreCondition.assertNotEmpty(alias, "alias");
6353
+ PreCondition.assertFalse(this.nameOrAliasExists(alias), "this.nameOrAliasExists(alias)");
6354
+ if (this.aliases === void 0) {
6355
+ this.aliases = List.create();
6356
+ }
6357
+ this.aliases.add(alias);
6358
+ return this;
6359
+ }
6360
+ addAliases(aliases) {
6361
+ for (const alias of aliases) {
6362
+ this.addAlias(alias);
6363
+ }
6364
+ return this;
6365
+ }
6366
+ getNameAndAliases() {
6367
+ return List.create().add(this.getName()).addAll(this.getAliases());
6368
+ }
6369
+ getDescription() {
6370
+ return this.description ?? "";
6371
+ }
6372
+ setDescription(description) {
6373
+ PreCondition.assertNotUndefinedAndNotNull(description, "description");
6374
+ this.description = description;
6375
+ return this;
5894
6376
  }
5895
6377
  };
5896
6378
 
@@ -6818,14 +7300,14 @@ var CurrentProcess = class _CurrentProcess {
6818
7300
  }
6819
7301
  getArguments() {
6820
7302
  if (!this.args) {
6821
- this.args = process.argv;
7303
+ this.args = Iterable.create(process.argv);
6822
7304
  }
6823
7305
  return this.args;
6824
7306
  }
6825
7307
  setArguments(args) {
6826
7308
  PreCondition.assertNotUndefinedAndNotNull(args, "args");
6827
7309
  PreCondition.assertUndefined(this.parameters, "this.parameters");
6828
- this.args = args;
7310
+ this.args = isIterable(args) ? args : Iterable.create(args);
6829
7311
  return this;
6830
7312
  }
6831
7313
  getParameters() {
@@ -7038,6 +7520,9 @@ var ListStack = class _ListStack {
7038
7520
  any() {
7039
7521
  return this.list.any();
7040
7522
  }
7523
+ getCount() {
7524
+ return this.list.getCount();
7525
+ }
7041
7526
  add(value) {
7042
7527
  return SyncResult.create(() => {
7043
7528
  this.list.add(value);
@@ -7084,7 +7569,7 @@ var DepthFirstSearch = class _DepthFirstSearch {
7084
7569
  started;
7085
7570
  done;
7086
7571
  constructor(initialToVisit, searchAction) {
7087
- PreCondition.assertNotEmpty(initialToVisit, "initialToVisit");
7572
+ PreCondition.assertNotUndefinedAndNotNull(initialToVisit, "initialToVisit");
7088
7573
  PreCondition.assertNotUndefinedAndNotNull(searchAction, "searchAction");
7089
7574
  this.searchAction = searchAction;
7090
7575
  this.toVisit = Stack.create();
@@ -7226,37 +7711,6 @@ var Disposable = class {
7226
7711
  }
7227
7712
  };
7228
7713
 
7229
- // sources/english.ts
7230
- function andList(values) {
7231
- return list("and", values);
7232
- }
7233
- function orList(values) {
7234
- return list("or", values);
7235
- }
7236
- function list(conjunction, values) {
7237
- PreCondition.assertNotEmpty(conjunction, "conjunction");
7238
- PreCondition.assertNotUndefinedAndNotNull(values, "values");
7239
- let result = "";
7240
- let index = 0;
7241
- const iterator = Iterator.create(values).start().await();
7242
- while (iterator.hasCurrent()) {
7243
- const currentValue = iterator.takeCurrent().await();
7244
- if (index >= 1) {
7245
- if (iterator.hasCurrent()) {
7246
- result += `, `;
7247
- } else {
7248
- if (index >= 2) {
7249
- result += `,`;
7250
- }
7251
- result += ` ${conjunction} `;
7252
- }
7253
- }
7254
- result += currentValue;
7255
- index++;
7256
- }
7257
- return result;
7258
- }
7259
-
7260
7714
  // sources/generator.ts
7261
7715
  var InnerGeneratorControl = class _InnerGeneratorControl {
7262
7716
  returnValues;
@@ -8844,6 +9298,7 @@ var WonderlandTrailClient = class _WonderlandTrailClient {
8844
9298
  };
8845
9299
  // Annotate the CommonJS export names for ESM import in node:
8846
9300
  0 && (module.exports = {
9301
+ ANSIStyles,
8847
9302
  AsyncIterator,
8848
9303
  AsyncIteratorToJavascriptAsyncIteratorAdapter,
8849
9304
  AsyncResult,
@@ -8856,6 +9311,7 @@ var WonderlandTrailClient = class _WonderlandTrailClient {
8856
9311
  CharacterListStream,
8857
9312
  CharacterReadStream,
8858
9313
  CharacterReadStreamAsyncIterator,
9314
+ CharacterTable,
8859
9315
  CharacterWriteStream,
8860
9316
  CommandLineParameter,
8861
9317
  CommandLineParameters,
@@ -8885,6 +9341,8 @@ var WonderlandTrailClient = class _WonderlandTrailClient {
8885
9341
  HttpOutgoingResponse,
8886
9342
  HttpServer,
8887
9343
  InMemoryCharacterWriteStream,
9344
+ IndentedCharacterWriteStream,
9345
+ Indexable,
8888
9346
  Iterable,
8889
9347
  Iterator,
8890
9348
  IteratorToJavascriptIteratorAdapter,
@@ -8905,6 +9363,7 @@ var WonderlandTrailClient = class _WonderlandTrailClient {
8905
9363
  MapIterator,
8906
9364
  MutableCondition,
8907
9365
  MutableHttpHeaders,
9366
+ MutableIndexable,
8908
9367
  MutableMap,
8909
9368
  Network,
8910
9369
  Node,