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