* Guard an Array-format assets option and converted it * into the key-value Object format. * * @param {Object|Array} assets * @return {Object}
(assets)
| 1854 | */ |
| 1855 | |
| 1856 | function guardArrayAssets(assets) { |
| 1857 | if (isArray(assets)) { |
| 1858 | var res = {}; |
| 1859 | var i = assets.length; |
| 1860 | var asset; |
| 1861 | while (i--) { |
| 1862 | asset = assets[i]; |
| 1863 | var id = typeof asset === 'function' ? asset.options && asset.options.name || asset.id : asset.name || asset.id; |
| 1864 | if (!id) { |
| 1865 | 'development' !== 'production' && warn('Array-syntax assets must provide a "name" or "id" field.'); |
| 1866 | } else { |
| 1867 | res[id] = asset; |
| 1868 | } |
| 1869 | } |
| 1870 | return res; |
| 1871 | } |
| 1872 | return assets; |
| 1873 | } |
| 1874 | |
| 1875 | /** |
| 1876 | * Merge two option objects into a new one. |
no test coverage detected