diff --git a/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts b/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts index ecce7979..215c7250 100644 --- a/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts +++ b/src/custom-code-helpers/string-array/StringArrayCodeHelper.ts @@ -33,6 +33,12 @@ export class StringArrayCodeHelper extends AbstractCustomCodeHelper { @initializable() private stringArrayName!: string; + /** + * @type {string} + */ + @initializable() + private stringArrayFunctionName!: string; + /** * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter @@ -59,13 +65,16 @@ export class StringArrayCodeHelper extends AbstractCustomCodeHelper { /** * @param {IStringArrayStorage} stringArrayStorage + * @param {string} stringArrayFunctionName * @param {string} stringArrayName */ public initialize ( stringArrayStorage: IStringArrayStorage, + stringArrayFunctionName: string, stringArrayName: string ): void { this.stringArrayStorage = stringArrayStorage; + this.stringArrayFunctionName = stringArrayFunctionName; this.stringArrayName = stringArrayName; } @@ -83,6 +92,7 @@ export class StringArrayCodeHelper extends AbstractCustomCodeHelper { protected override getCodeHelperTemplate (): string { return this.customCodeHelperFormatter.formatTemplate(StringArrayTemplate(), { stringArrayName: this.stringArrayName, + stringArrayFunctionName: this.stringArrayFunctionName, stringArrayStorageItems: this.getEncodedStringArrayStorageItems() }); } diff --git a/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts b/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts index 3201359e..c67a2571 100644 --- a/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts +++ b/src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts @@ -122,9 +122,14 @@ export class StringArrayCodeHelperGroup extends AbstractCustomCodeHelperGroup { // stringArray helper initialize const stringArrayCodeHelper: ICustomCodeHelper> = this.customCodeHelperFactory(CustomCodeHelper.StringArray); + const stringArrayFunctionName: string = this.stringArrayStorage.getStorageFunctionName(); const stringArrayName: string = this.stringArrayStorage.getStorageName(); - stringArrayCodeHelper.initialize(this.stringArrayStorage, stringArrayName); + stringArrayCodeHelper.initialize( + this.stringArrayStorage, + stringArrayFunctionName, + stringArrayName + ); this.customCodeHelpers.set(CustomCodeHelper.StringArray, stringArrayCodeHelper); // stringArrayCallsWrapper helper initialize diff --git a/src/custom-code-helpers/string-array/templates/string-array/StringArrayTemplate.ts b/src/custom-code-helpers/string-array/templates/string-array/StringArrayTemplate.ts index 6d5447c8..52417df0 100644 --- a/src/custom-code-helpers/string-array/templates/string-array/StringArrayTemplate.ts +++ b/src/custom-code-helpers/string-array/templates/string-array/StringArrayTemplate.ts @@ -3,6 +3,10 @@ */ export function StringArrayTemplate (): string { return ` - const {stringArrayName} = [{stringArrayStorageItems}]; + const {stringArrayFunctionName} = function () { + return [{stringArrayStorageItems}]; + }; + + const {stringArrayName} = {stringArrayFunctionName}(); `; } diff --git a/src/interfaces/storages/string-array-transformers/IStringArrayStorage.ts b/src/interfaces/storages/string-array-transformers/IStringArrayStorage.ts index a80d3d96..b534ca72 100644 --- a/src/interfaces/storages/string-array-transformers/IStringArrayStorage.ts +++ b/src/interfaces/storages/string-array-transformers/IStringArrayStorage.ts @@ -19,6 +19,11 @@ export interface IStringArrayStorage extends IMapStorage