function mapLaunchStoryboardContents()

in lib/prepare.js [926:980]


function mapLaunchStoryboardContents (splashScreens, launchStoryboardImagesDir) {
    const platformLaunchStoryboardImages = [];
    const idioms = ['universal', 'ipad', 'iphone'];
    const scalesForIdiom = {
        universal: ['1x', '2x', '3x'],
        ipad: ['1x', '2x'],
        iphone: ['1x', '2x', '3x']
    };
    const sizes = ['com', 'any'];
    const appearences = ['', 'dark', 'light'];

    idioms.forEach(idiom => {
        scalesForIdiom[idiom].forEach(scale => {
            sizes.forEach(width => {
                sizes.forEach(height => {
                    appearences.forEach(appearence => {
                        const item = { idiom, scale, width, height };

                        if (appearence !== '') {
                            item.appearence = appearence;
                        }

                        /* examples of the search pattern:
                         *    scale   ~  idiom    ~   width    height ~ appearence
                         *     @2x    ~ universal ~    any      any
                         *     @3x    ~  iphone   ~    com      any   ~   dark
                         *     @2x    ~   ipad    ~    com      any   ~   light
                         */
                        const searchPattern = '@' + scale + '~' + idiom + '~' + width + height + (appearence ? '~' + appearence : '');

                        /* because old node versions don't have Array.find, the below is
                         * functionally equivalent to this:
                         *     var launchStoryboardImage = splashScreens.find(function(item) {
                         *         return (item.src.indexOf(searchPattern) >= 0) ? (appearence !== '' ? true : ((item.src.indexOf(searchPattern + '~light') >= 0 || (item.src.indexOf(searchPattern + '~dark') >= 0)) ? false : true)) : false;
                         *     });
                         */
                        const launchStoryboardImage = splashScreens.reduce(
                            (p, c) => (c.src.indexOf(searchPattern) >= 0) ? (appearence !== '' ? c : ((c.src.indexOf(searchPattern + '~light') >= 0 || (c.src.indexOf(searchPattern + '~dark') >= 0)) ? p : c)) : p,
                            undefined
                        );

                        if (launchStoryboardImage) {
                            item.filename = `Default${searchPattern}.png`;
                            item.src = launchStoryboardImage.src;
                            item.target = path.join(launchStoryboardImagesDir, item.filename);
                        }

                        platformLaunchStoryboardImages.push(item);
                    });
                });
            });
        });
    });
    return platformLaunchStoryboardImages;
}