Skip to content

Commit

Permalink
fix(array-utils): rename ArrayUtils to TokenListUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
Sisha0 committed Apr 30, 2021
1 parent 1702b7a commit 404cfcd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/settings/setting/bool-setting/bool-setting.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(' ');
Expand All @@ -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();
}

Expand Down
8 changes: 4 additions & 4 deletions src/settings/setting/select-setting/select-setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(' ');
Expand All @@ -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 {
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default class ArrayUtils {
export default class TokenListUtils {
static equals<T>(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<T>(array: T[], subArray: T[]): boolean {
Expand Down

0 comments on commit 404cfcd

Please sign in to comment.