mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 21:25:26 +00:00
Improved splitBufferBundle with early return
This commit is contained in:
11
src/utils.ts
11
src/utils.ts
@@ -90,9 +90,11 @@ export function generateStringFile(lang: { [index: string]: string }): Buffer {
|
||||
*/
|
||||
|
||||
export function splitBufferBundle(origin: Object): [PartitionedBundle["l10nBundle"], PartitionedBundle["bundle"]] {
|
||||
const keys = Object.keys(origin);
|
||||
return keys.reduce(([ l10n, bundle ], current) => {
|
||||
if (current.includes(".lproj")) {
|
||||
return Object.keys(origin).reduce(([ l10n, bundle ], current) => {
|
||||
if (!current.includes(".lproj")) {
|
||||
return [ l10n, { ...bundle, [current]: origin[current] }];
|
||||
}
|
||||
|
||||
const pathComponents = current.split(sep);
|
||||
const lang = pathComponents[0];
|
||||
const file = pathComponents.slice(1).join("/");
|
||||
@@ -100,9 +102,6 @@ export function splitBufferBundle(origin: Object): [PartitionedBundle["l10nBundl
|
||||
(l10n[lang] || (l10n[lang] = {}))[file] = origin[current];
|
||||
|
||||
return [ l10n, bundle ];
|
||||
} else {
|
||||
return [ l10n, { ...bundle, [current]: origin[current] }];
|
||||
}
|
||||
}, [{},{}]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user