@stemy/ngx-utils 19.7.22 → 19.7.23

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.
@@ -332,6 +332,19 @@ class ObjectUtils {
332
332
  static assign(target, source, predicate) {
333
333
  return ObjectUtils.copyRecursive(target, source, predicate || defaultPredicate, new Map());
334
334
  }
335
+ static hashCode(obj) {
336
+ let hash = 0;
337
+ ObjectUtils.copyRecursive(null, obj, value => {
338
+ const str = JSON.stringify(value ?? "") || "";
339
+ for (let i = 0, len = str.length; i < len; i++) {
340
+ const chr = str.charCodeAt(i);
341
+ hash = (hash << 5) - hash + chr;
342
+ hash |= 0; // Convert to 32bit integer
343
+ }
344
+ return true;
345
+ }, new Map());
346
+ return hash;
347
+ }
335
348
  static getType(obj) {
336
349
  const regex = new RegExp("\\s([a-zA-Z]+)");
337
350
  const target = !obj ? null : obj.constructor;
@@ -3128,7 +3141,7 @@ class RequestBag {
3128
3141
  return new HttpHeaders(headers);
3129
3142
  }
3130
3143
  makeParams(paramsObj) {
3131
- const params = Object.assign({}, this.params?.headers || {}, this.params, paramsObj);
3144
+ const params = Object.assign({}, this.source?.params || {}, this.params, paramsObj);
3132
3145
  return new HttpParams({
3133
3146
  encoder: new HttpUrlEncodingCodec(),
3134
3147
  fromObject: Object.keys(params || {}).reduce((result, key) => {
@@ -3183,6 +3196,9 @@ class BaseHttpClient extends HttpClient {
3183
3196
  setParam(name, value) {
3184
3197
  this.bag.setParam(name, value);
3185
3198
  }
3199
+ setExtraRequestParam(name, value) {
3200
+ this.bag.setParam(name, value);
3201
+ }
3186
3202
  makeHeaders() {
3187
3203
  return this.bag.makeHeaders();
3188
3204
  }
@@ -3432,7 +3448,7 @@ class BaseHttpService {
3432
3448
  toPromise(url, requestOptions, listener) {
3433
3449
  const { cache, read, ...options } = requestOptions;
3434
3450
  const absoluteUrl = this.absoluteUrl(url, options);
3435
- const cacheKey = `request-${hashCode(absoluteUrl)}-${hashCode(options)}`;
3451
+ const cacheKey = `request-${ObjectUtils.hashCode(absoluteUrl)}-${ObjectUtils.hashCode(options)}`;
3436
3452
  const issueContext = { url: absoluteUrl };
3437
3453
  return this.caches.use(`${cacheKey}-${read}`, async () => {
3438
3454
  const response = await this.caches.use(cacheKey, () => new HttpPromise(response => {