From 931bfa138c1030f75c821a55f2649aaf32d2fd6e Mon Sep 17 00:00:00 2001 From: tom910 Date: Fri, 24 Dec 2021 23:16:55 +0300 Subject: [PATCH] fix: improved asymptotic of extend func from O(n^2) to o(n) --- .../services/browser-micro-sentry-client.ts | 6 +++--- .../src/lib/service/micro-sentry-client.ts | 20 +------------------ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/libs/browser/src/lib/services/browser-micro-sentry-client.ts b/libs/browser/src/lib/services/browser-micro-sentry-client.ts index abd08e9..ebb34f1 100644 --- a/libs/browser/src/lib/services/browser-micro-sentry-client.ts +++ b/libs/browser/src/lib/services/browser-micro-sentry-client.ts @@ -11,6 +11,7 @@ import { State } from '../models/state'; import { MicroSentryPlugin } from '../models/plugin'; import { BrowserSentryClientOptions } from '../models/browser-sentry-client-options'; import { isMatchingPattern } from '../utils/is-matching-pattern'; +import { __assign } from 'tslib'; export class BrowserMicroSentryClient extends MicroSentryClient { private destroyed = false; @@ -233,8 +234,7 @@ export class BrowserMicroSentryClient extends MicroSentryClient { ? newStateValue : null; - return { - ...acc, + return __assign(acc, { [key]: stateArray || newStateArray ? [...(stateArray || []), ...(newStateArray || [])] @@ -242,7 +242,7 @@ export class BrowserMicroSentryClient extends MicroSentryClient { ...(typeof stateValue !== 'string' ? stateValue : {}), ...(typeof newStateValue !== 'string' ? newStateValue : {}), }, - }; + }); }, {} ); diff --git a/libs/core/src/lib/service/micro-sentry-client.ts b/libs/core/src/lib/service/micro-sentry-client.ts index e29b865..a793d09 100644 --- a/libs/core/src/lib/service/micro-sentry-client.ts +++ b/libs/core/src/lib/service/micro-sentry-client.ts @@ -2,25 +2,7 @@ import { SentryRequest } from '../models/models'; import { AUTH_HEADER, DSN_REGEXP } from '../consts/consts'; import { computeStackTrace } from '../helpers/compute-stack-trace'; import { SentryClientOptions } from '../models/sentry-client-options'; - -const __assign = - Object.assign || - function __assign(target: Record) { - const length = arguments.length; - - for (let i = 1; i < length; i++) { - // eslint-disable-next-line prefer-rest-params - const source = arguments[i]; - - for (const property in source) { - if (Object.prototype.hasOwnProperty.call(source, property)) { - target[property] = source[property]; - } - } - } - - return target; - }; +import { __assign } from 'tslib'; export class MicroSentryClient { readonly authHeader?: string;