@stemy/ngx-utils 19.7.21 → 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) => {
@@ -3145,6 +3158,9 @@ class RequestBag {
3145
3158
  }
3146
3159
  this.headers[name] = value;
3147
3160
  }
3161
+ getHeader(name) {
3162
+ return String(this.headers[name] || "");
3163
+ }
3148
3164
  setParam(name, value) {
3149
3165
  if (value === undefined) {
3150
3166
  delete this.params[name];
@@ -3174,9 +3190,15 @@ class BaseHttpClient extends HttpClient {
3174
3190
  setHeader(name, value) {
3175
3191
  this.bag.setHeader(name, value);
3176
3192
  }
3193
+ getHeader(name) {
3194
+ return this.bag.getHeader(name);
3195
+ }
3177
3196
  setParam(name, value) {
3178
3197
  this.bag.setParam(name, value);
3179
3198
  }
3199
+ setExtraRequestParam(name, value) {
3200
+ this.bag.setParam(name, value);
3201
+ }
3180
3202
  makeHeaders() {
3181
3203
  return this.bag.makeHeaders();
3182
3204
  }
@@ -3426,7 +3448,7 @@ class BaseHttpService {
3426
3448
  toPromise(url, requestOptions, listener) {
3427
3449
  const { cache, read, ...options } = requestOptions;
3428
3450
  const absoluteUrl = this.absoluteUrl(url, options);
3429
- const cacheKey = `request-${hashCode(absoluteUrl)}-${hashCode(options)}`;
3451
+ const cacheKey = `request-${ObjectUtils.hashCode(absoluteUrl)}-${ObjectUtils.hashCode(options)}`;
3430
3452
  const issueContext = { url: absoluteUrl };
3431
3453
  return this.caches.use(`${cacheKey}-${read}`, async () => {
3432
3454
  const response = await this.caches.use(cacheKey, () => new HttpPromise(response => {