From 404cfcddebed1b6817617b2fd7b9ec99b34f944b Mon Sep 17 00:00:00 2001 From: apalanevich Date: Fri, 30 Apr 2021 19:34:37 +0300 Subject: [PATCH] fix(array-utils): rename ArrayUtils to TokenListUtils --- src/settings/setting/bool-setting/bool-setting.ts | 8 ++++---- src/settings/setting/select-setting/select-setting.ts | 8 ++++---- .../array-utils/{array-utils.ts => token-list-utils.ts} | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) rename src/utils/array-utils/{array-utils.ts => token-list-utils.ts} (77%) diff --git a/src/settings/setting/bool-setting/bool-setting.ts b/src/settings/setting/bool-setting/bool-setting.ts index 6c4cda3d..17cb1c4d 100644 --- a/src/settings/setting/bool-setting/bool-setting.ts +++ b/src/settings/setting/bool-setting/bool-setting.ts @@ -1,7 +1,7 @@ import {UIPSetting} from '../setting'; import {attr} from '@exadel/esl/modules/esl-base-element/core'; import {UIPStateModel} from '../../../utils/state-model/state-model'; -import ArrayUtils from '../../../utils/array-utils/array-utils'; +import TokenListUtils from '../../../utils/array-utils/token-list-utils'; export class UIPBoolSetting extends UIPSetting { public static is = 'uip-bool-setting'; @@ -42,7 +42,7 @@ export class UIPBoolSetting extends UIPSetting { return val || null; } - const attrTokens = ArrayUtils.remove(attrValue.split(/\s+/), this.value); + const attrTokens = TokenListUtils.remove(attrValue.split(/\s+/), this.value); val && attrTokens.push(val); return attrTokens.join(' '); @@ -64,8 +64,8 @@ export class UIPBoolSetting extends UIPSetting { } const valueMatch = attrValues.map(attrValue => - ArrayUtils.intersection([this.value], attrValue?.split(' ') || [])); - valueMatch.every(match => ArrayUtils.equals(match, valueMatch[0])) ? + TokenListUtils.intersection([this.value], attrValue?.split(' ') || [])); + valueMatch.every(match => TokenListUtils.equals(match, valueMatch[0])) ? this.setValue(valueMatch[0].length ? this.value : null) : this.setInconsistency(); } diff --git a/src/settings/setting/select-setting/select-setting.ts b/src/settings/setting/select-setting/select-setting.ts index 36ab2950..51d5b5fd 100644 --- a/src/settings/setting/select-setting/select-setting.ts +++ b/src/settings/setting/select-setting/select-setting.ts @@ -2,7 +2,7 @@ import {attr, boolAttr} from '@exadel/esl/modules/esl-base-element/core'; import {UIPSetting} from '../setting'; import {ESLSelect} from '@exadel/esl'; import {UIPStateModel} from '../../../utils/state-model/state-model'; -import ArrayUtils from '../../../utils/array-utils/array-utils'; +import TokenListUtils from '../../../utils/array-utils/token-list-utils'; import {generateUId} from '@exadel/esl/modules/esl-utils/misc/uid'; export class UIPSelectSetting extends UIPSetting { @@ -66,7 +66,7 @@ export class UIPSelectSetting extends UIPSetting { } const attrTokens = this.values.reduce((tokens, option) => - ArrayUtils.remove(tokens, option), attrValue.split(/\s+/)); + TokenListUtils.remove(tokens, option), attrValue.split(/\s+/)); val && attrTokens.push(val); return attrTokens.join(' '); @@ -78,7 +78,7 @@ export class UIPSelectSetting extends UIPSetting { const attrValues = model.getAttribute(this.target, this.attribute); if (this.mode === 'replace') { - if (attrValues[0] && ArrayUtils.contains(settingOptions, attrValues[0].split(' ')) && + if (attrValues[0] && TokenListUtils.contains(settingOptions, attrValues[0].split(' ')) && attrValues.every(val => val === attrValues[0])) { this.setValue(attrValues[0]); } else { @@ -89,7 +89,7 @@ export class UIPSelectSetting extends UIPSetting { } const attrTokens = attrValues.map(value => value?.split(' ') || []); - const valueTokens = ArrayUtils.intersection(settingOptions, ...attrTokens); + const valueTokens = TokenListUtils.intersection(settingOptions, ...attrTokens); valueTokens.length ? this.setValue(valueTokens.join(' ')) : this.setInconsistency(); } diff --git a/src/utils/array-utils/array-utils.ts b/src/utils/array-utils/token-list-utils.ts similarity index 77% rename from src/utils/array-utils/array-utils.ts rename to src/utils/array-utils/token-list-utils.ts index 43f21214..f2385466 100644 --- a/src/utils/array-utils/array-utils.ts +++ b/src/utils/array-utils/token-list-utils.ts @@ -1,6 +1,6 @@ -export default class ArrayUtils { +export default class TokenListUtils { static equals(arr1: T[], arr2: T[]): boolean { - return ArrayUtils.contains(arr1, arr2) && ArrayUtils.contains(arr2, arr1); + return TokenListUtils.contains(arr1, arr2) && TokenListUtils.contains(arr2, arr1); } static contains(array: T[], subArray: T[]): boolean {