MCPcopy
hub / github.com/keepfool/vue-tutorials / guardArrayAssets

Function guardArrayAssets

06.Router/basic/js/vue.js:1856–1873  ·  view source on GitHub ↗

* Guard an Array-format assets option and converted it * into the key-value Object format. * * @param {Object|Array} assets * @return {Object}

(assets)

Source from the content-addressed store, hash-verified

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.

Callers 2

mergeAssetsFunction · 0.70
guardComponentsFunction · 0.70

Calls 2

isArrayFunction · 0.85
warnFunction · 0.70

Tested by

no test coverage detected