MCPcopy
hub / github.com/fanmingming/live / normalizeInject

Function normalizeInject

m3u8/vue.js:1467–1489  ·  view source on GitHub ↗

* Normalize all injections into Object-based format

(options, vm)

Source from the content-addressed store, hash-verified

1465 * Normalize all injections into Object-based format
1466 */
1467 function normalizeInject (options, vm) {
1468 var inject = options.inject;
1469 if (!inject) { return }
1470 var normalized = options.inject = {};
1471 if (Array.isArray(inject)) {
1472 for (var i = 0; i < inject.length; i++) {
1473 normalized[inject[i]] = { from: inject[i] };
1474 }
1475 } else if (isPlainObject(inject)) {
1476 for (var key in inject) {
1477 var val = inject[key];
1478 normalized[key] = isPlainObject(val)
1479 ? extend({ from: key }, val)
1480 : { from: val };
1481 }
1482 } else {
1483 warn(
1484 "Invalid value for option \"inject\": expected an Array or an Object, " +
1485 "but got " + (toRawType(inject)) + ".",
1486 vm
1487 );
1488 }
1489 }
1490
1491 /**
1492 * Normalize raw function directives into object format.

Callers 1

mergeOptionsFunction · 0.85

Calls 4

isPlainObjectFunction · 0.85
extendFunction · 0.85
warnFunction · 0.85
toRawTypeFunction · 0.85

Tested by

no test coverage detected