jsf.js_next_gen 4.0.0-RC.32 → 4.0.0-RC.34

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.
@@ -2917,8 +2917,9 @@ exports.Config = Config;
2917
2917
  * limitations under the License.
2918
2918
  */
2919
2919
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2920
- exports.QueryFormStringCollector = exports.QueryFormDataCollector = exports.FormDataCollector = exports.AssocArrayCollector = exports.Run = exports.ArrayAssocArrayCollector = exports.InverseArrayCollector = exports.ArrayCollector = exports.FlatMapStreamDataSource = exports.MappedStreamDataSource = exports.FilteredStreamDatasource = exports.ArrayStreamDataSource = exports.SequenceDataSource = exports.MultiStreamDatasource = exports.ITERATION_STATUS = void 0;
2920
+ exports.QueryFormStringCollector = exports.QueryFormDataCollector = exports.FormDataCollector = exports.ConfigCollector = exports.AssocArrayCollector = exports.Run = exports.ArrayAssocArrayCollector = exports.InverseArrayCollector = exports.ArrayCollector = exports.FlatMapStreamDataSource = exports.MappedStreamDataSource = exports.FilteredStreamDatasource = exports.ArrayStreamDataSource = exports.SequenceDataSource = exports.MultiStreamDatasource = exports.ITERATION_STATUS = void 0;
2921
2921
  const Stream_1 = __webpack_require__(/*! ./Stream */ "./node_modules/mona-dish/src/main/typescript/Stream.ts");
2922
+ const Monad_1 = __webpack_require__(/*! ./Monad */ "./node_modules/mona-dish/src/main/typescript/Monad.ts");
2922
2923
  /**
2923
2924
  * special status of the datasource location pointer
2924
2925
  * if an access, outside of the possible data boundaries is happening
@@ -2935,6 +2936,13 @@ var ITERATION_STATUS;
2935
2936
  ITERATION_STATUS["EO_STRM"] = "__EO_STRM__";
2936
2937
  ITERATION_STATUS["BEF_STRM"] = "___BEF_STRM__";
2937
2938
  })(ITERATION_STATUS = exports.ITERATION_STATUS || (exports.ITERATION_STATUS = {}));
2939
+ function calculateSkips(next_strm) {
2940
+ let pos = 1;
2941
+ while (next_strm.lookAhead(pos) != ITERATION_STATUS.EO_STRM) {
2942
+ pos++;
2943
+ }
2944
+ return --pos;
2945
+ }
2938
2946
  class MultiStreamDatasource {
2939
2947
  constructor(first, ...strms) {
2940
2948
  this.first = first;
@@ -2965,33 +2973,22 @@ class MultiStreamDatasource {
2965
2973
  }
2966
2974
  return hasNext ? cnt : -1;
2967
2975
  }
2968
- lookAhead(cnt) {
2969
- let posPtr = 1;
2970
- let strmPos = this.selectedPos;
2971
- let valueFound = null;
2972
- if (this.strms[strmPos].lookAhead(cnt) != ITERATION_STATUS.EO_STRM) {
2973
- //speedup
2974
- return this.strms[strmPos].lookAhead(cnt);
2976
+ lookAhead(cnt = 1) {
2977
+ //lets clone
2978
+ const strms = this.strms.slice(this.selectedPos);
2979
+ if (!strms.length) {
2980
+ return ITERATION_STATUS.EO_STRM;
2975
2981
  }
2976
- for (let loop = posPtr; loop <= cnt; loop++) {
2977
- if (!this.strms[strmPos]) {
2978
- return ITERATION_STATUS.EO_STRM;
2979
- }
2980
- let val = (posPtr > 0) ? this.strms[strmPos].lookAhead(posPtr) : this.strms[strmPos].current();
2981
- valueFound = val;
2982
- if (val != ITERATION_STATUS.EO_STRM) {
2983
- posPtr++;
2984
- }
2985
- else {
2986
- if (strmPos >= this.strms.length) {
2987
- return ITERATION_STATUS.EO_STRM;
2988
- }
2989
- strmPos++;
2990
- posPtr = 1;
2991
- loop--; //empty iteration
2982
+ const all_strms = [...strms];
2983
+ while (all_strms.length) {
2984
+ let next_strm = all_strms.shift();
2985
+ let lookAhead = next_strm.lookAhead(cnt);
2986
+ if (lookAhead != ITERATION_STATUS.EO_STRM) {
2987
+ return lookAhead;
2992
2988
  }
2989
+ cnt = cnt - calculateSkips(next_strm);
2993
2990
  }
2994
- return valueFound;
2991
+ return ITERATION_STATUS.EO_STRM;
2995
2992
  }
2996
2993
  next() {
2997
2994
  if (this.activeStrm.hasNext()) {
@@ -3206,48 +3203,39 @@ class FlatMapStreamDataSource {
3206
3203
  }
3207
3204
  lookAhead(cnt = 1) {
3208
3205
  var _a;
3209
- //easy access trial
3210
- if ((this === null || this === void 0 ? void 0 : this.activeDataSource) && ((_a = this === null || this === void 0 ? void 0 : this.activeDataSource) === null || _a === void 0 ? void 0 : _a.lookAhead(cnt)) != ITERATION_STATUS.EO_STRM) {
3211
- //this should coverr 95% of all accesses
3212
- return this === null || this === void 0 ? void 0 : this.activeDataSource.lookAhead(cnt);
3213
- }
3214
- /**
3215
- * we only can determine how many elems datasource has by going up
3216
- * (for now this suffices, however not ideal, we might have to introduce a numElements or so)
3217
- * @param datasource
3218
- */
3219
- function howManyElems(datasource) {
3220
- let cnt = 1;
3221
- while (datasource.lookAhead(cnt) !== ITERATION_STATUS.EO_STRM) {
3222
- cnt++;
3223
- }
3224
- return cnt - 1;
3225
- }
3226
- function readjustSkip(dataSource) {
3227
- let skippedElems = (dataSource) ? howManyElems(dataSource) : 0;
3228
- cnt = cnt - skippedElems;
3206
+ let lookAhead = (_a = this === null || this === void 0 ? void 0 : this.activeDataSource) === null || _a === void 0 ? void 0 : _a.lookAhead(cnt);
3207
+ if ((this === null || this === void 0 ? void 0 : this.activeDataSource) && lookAhead != ITERATION_STATUS.EO_STRM) {
3208
+ //this should cover 95% of all cases
3209
+ return lookAhead;
3229
3210
  }
3230
3211
  if (this.activeDataSource) {
3231
- readjustSkip(this.activeDataSource);
3212
+ cnt -= calculateSkips(this.activeDataSource);
3232
3213
  }
3233
- //the idea is basically to look into the streams subsequentially for a match
3214
+ //the idea is basically to look into the streams sub-sequentially for a match
3234
3215
  //after each stream we have to take into consideration that the skipCnt is
3235
3216
  //reduced by the number of datasets we already have looked into in the previous stream/datasource
3236
- //unfortunately for now we have to loop into them so we introduce a small o2 here
3217
+ //unfortunately for now we have to loop into them, so we introduce a small o2 here
3237
3218
  for (let dsLoop = 1; true; dsLoop++) {
3238
- let currDatasource = this.inputDataSource.lookAhead(dsLoop);
3219
+ let datasourceData = this.inputDataSource.lookAhead(dsLoop);
3239
3220
  //we have looped out
3240
- if (currDatasource === ITERATION_STATUS.EO_STRM) {
3221
+ //no embedded data anymore? we are done, data
3222
+ //can either be a scalar an array or another datasource
3223
+ if (datasourceData === ITERATION_STATUS.EO_STRM) {
3241
3224
  return ITERATION_STATUS.EO_STRM;
3242
3225
  }
3243
- let mapped = this.mapFunc(currDatasource);
3226
+ let mappedData = this.mapFunc(datasourceData);
3244
3227
  //it either comes in as datasource or as array
3245
- let currentDataSource = this.toDatasource(mapped);
3228
+ //both cases must be unified into a datasource
3229
+ let currentDataSource = this.toDatasource(mappedData);
3230
+ //we now run again a lookahead
3246
3231
  let ret = currentDataSource.lookAhead(cnt);
3232
+ //if the value is found then we are set
3247
3233
  if (ret != ITERATION_STATUS.EO_STRM) {
3248
3234
  return ret;
3249
3235
  }
3250
- readjustSkip(currDatasource);
3236
+ //reduce the next lookahead by the number of elements
3237
+ //we are now skipping in the current data source
3238
+ cnt -= calculateSkips(currentDataSource);
3251
3239
  }
3252
3240
  }
3253
3241
  toDatasource(mapped) {
@@ -3260,7 +3248,6 @@ class FlatMapStreamDataSource {
3260
3248
  while (!next && this.inputDataSource.hasNext()) {
3261
3249
  let mapped = this.mapFunc(this.inputDataSource.next());
3262
3250
  this.activeDataSource = this.toDatasource(mapped);
3263
- ;
3264
3251
  next = this.activeDataSource.hasNext();
3265
3252
  }
3266
3253
  return next;
@@ -3358,6 +3345,18 @@ class AssocArrayCollector {
3358
3345
  }
3359
3346
  }
3360
3347
  exports.AssocArrayCollector = AssocArrayCollector;
3348
+ /**
3349
+ * A Config collector similar to the FormDFata Collector
3350
+ */
3351
+ class ConfigCollector {
3352
+ constructor() {
3353
+ this.finalValue = new Monad_1.Config({});
3354
+ }
3355
+ collect(element) {
3356
+ this.finalValue.append(element.key).value = element.value;
3357
+ }
3358
+ }
3359
+ exports.ConfigCollector = ConfigCollector;
3361
3360
  /**
3362
3361
  * Form data collector for key value pair streams
3363
3362
  */
@@ -7770,15 +7769,10 @@ class XhrFormData extends mona_dish_1.Config {
7770
7769
  /*
7771
7770
  * collects everything into a FormData object
7772
7771
  */
7773
- let ret = new FormData();
7774
- let collectFormData = ({ key, item }) => {
7775
- ret.append(key, item);
7776
- };
7777
- mona_dish_1.Stream.ofAssoc(this.value)
7772
+ return mona_dish_1.Stream.ofAssoc(this.value)
7778
7773
  .flatMap(expandAssocArray)
7779
7774
  .map(remapForNamingContainer)
7780
- .each(collectFormData);
7781
- return ret;
7775
+ .collect(new mona_dish_1.FormDataCollector());
7782
7776
  }
7783
7777
  /**
7784
7778
  * returns an encoded string representation of our xhr form data
Binary file
Binary file