Uniformed factory cross-functions naming

This commit is contained in:
Alexander Cerutti
2019-06-01 00:45:20 +02:00
parent 6f25dc40cf
commit 66e224205e

View File

@@ -116,15 +116,15 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
} }
// Splitting files from localization folders // Splitting files from localization folders
const bundle = filteredFiles.filter(entry => !entry.includes(".lproj")); const rawBundle = filteredFiles.filter(entry => !entry.includes(".lproj"));
const l10nFolders = filteredFiles.filter(entry => entry.includes(".lproj")); const l10nFolders = filteredFiles.filter(entry => entry.includes(".lproj"));
const bundleBuffers = bundle.map(file => readFile(path.resolve(model, file))); const bundleBuffers = rawBundle.map(file => readFile(path.resolve(model, file)));
const buffers = await Promise.all(bundleBuffers); const buffers = await Promise.all(bundleBuffers);
const bundleMap = Object.assign({}, const bundle: BundleUnit = Object.assign({},
...bundle.map((fileName, index) => ({ [fileName]: buffers[index] })) ...rawBundle.map((fileName, index) => ({ [fileName]: buffers[index] }))
) as BundleUnit; );
// Reading concurrently localizations folder // Reading concurrently localizations folder
// and their files and their buffers // and their files and their buffers
@@ -158,7 +158,7 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
); );
return { return {
bundle: bundleMap, bundle,
l10nBundle l10nBundle
}; };
} }
@@ -170,17 +170,17 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
*/ */
function getModelBufferContents(model: BundleUnit): PartitionedBundle { function getModelBufferContents(model: BundleUnit): PartitionedBundle {
const bundle = removeHidden(Object.keys(model)).reduce<BundleUnit>((acc, current) => { const rawBundle = removeHidden(Object.keys(model)).reduce<BundleUnit>((acc, current) => {
// Checking if current file is one of the autogenerated ones or if its // Checking if current file is one of the autogenerated ones or if its
// content is not available // content is not available
if (/(manifest|signature)/.test(current) || !bundle[current]) { if (/(manifest|signature)/.test(current) || !rawBundle[current]) {
return acc; return acc;
} }
return { ...acc, [current]: model[current] }; return { ...acc, [current]: model[current] };
}, {}); }, {});
const bundleKeys = Object.keys(bundle); const bundleKeys = Object.keys(rawBundle);
if (!bundleKeys.length) { if (!bundleKeys.length) {
throw new Error("Cannot proceed with pass creation: bundle initialized") throw new Error("Cannot proceed with pass creation: bundle initialized")
@@ -189,19 +189,19 @@ function getModelBufferContents(model: BundleUnit): PartitionedBundle {
// separing localization folders // separing localization folders
const l10nFolders = bundleKeys.filter(file => file.includes(".lproj")); const l10nFolders = bundleKeys.filter(file => file.includes(".lproj"));
const l10nBundle: PartitionedBundle["l10nBundle"] = Object.assign({}, const l10nBundle: PartitionedBundle["l10nBundle"] = Object.assign({},
...l10nFolders.map(folder => ...l10nFolders.map<BundleUnit>(folder =>
({ [folder]: bundle[folder] }) as BundleUnit ({ [folder]: rawBundle[folder] })
) )
); );
const unLocalizedBundle: BundleUnit = Object.assign({}, const bundle: BundleUnit = Object.assign({},
...bundleKeys ...bundleKeys
.filter(file => !file.includes(".lproj")) .filter(file => !file.includes(".lproj"))
.map(file => ({ [file]: bundle[file] })) .map(file => ({ [file]: rawBundle[file] }))
); );
return { return {
bundle: unLocalizedBundle, bundle,
l10nBundle l10nBundle
}; };
} }