MCPcopy Create free account
hub / github.com/TruthHun/BookStack / initComputed

Function initComputed

static/vuejs/vue.runtime.common.js:2760–2785  ·  view source on GitHub ↗
(vm, computed)

Source from the content-addressed store, hash-verified

2758var computedWatcherOptions = { lazy: true };
2759
2760function initComputed (vm, computed) {
2761 var watchers = vm._computedWatchers = Object.create(null);
2762
2763 for (var key in computed) {
2764 var userDef = computed[key];
2765 var getter = typeof userDef === 'function' ? userDef : userDef.get;
2766 if (process.env.NODE_ENV !== 'production') {
2767 if (getter === undefined) {
2768 warn(
2769 ("No getter function has been defined for computed property \"" + key + "\"."),
2770 vm
2771 );
2772 getter = noop;
2773 }
2774 }
2775 // create internal watcher for the computed property.
2776 watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions);
2777
2778 // component-defined computed properties are already defined on the
2779 // component prototype. We only need to define computed properties defined
2780 // at instantiation here.
2781 if (!(key in vm)) {
2782 defineComputed(vm, key, userDef);
2783 }
2784 }
2785}
2786
2787function defineComputed (target, key, userDef) {
2788 if (typeof userDef === 'function') {

Callers 1

initStateFunction · 0.70

Calls 2

defineComputedFunction · 0.70
warnFunction · 0.50

Tested by

no test coverage detected