vue-async-computed
Advanced tools
Comparing version 3.2.1 to 3.3.0-rc1
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['module', 'exports'], factory); | ||
define(['module', 'exports', './lazy'], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(module, exports); | ||
factory(module, exports, require('./lazy')); | ||
} else { | ||
@@ -10,6 +10,6 @@ var mod = { | ||
}; | ||
factory(mod, mod.exports); | ||
factory(mod, mod.exports, global.lazy); | ||
global.AsyncComputed = mod.exports; | ||
} | ||
})(this, function (module, exports) { | ||
})(this, function (module, exports, _lazy) { | ||
'use strict'; | ||
@@ -20,2 +20,4 @@ | ||
}); | ||
var prefix = '_async_computed$'; | ||
@@ -36,3 +38,3 @@ | ||
for (var key in this.$options.asyncComputed || {}) { | ||
this.$options.computed[prefix + key] = getterFor(this.$options.asyncComputed[key]); | ||
this.$options.computed[prefix + key] = getterFn(key, this.$options.asyncComputed[key]); | ||
} | ||
@@ -43,3 +45,9 @@ | ||
for (var _key in this.$options.asyncComputed || {}) { | ||
data[_key] = null; | ||
var item = this.$options.asyncComputed[_key]; | ||
if ((0, _lazy.isComputedLazy)(item)) { | ||
(0, _lazy.initLazy)(data, _key); | ||
this.$options.computed[_key] = (0, _lazy.makeLazyComputed)(_key); | ||
} else { | ||
data[_key] = null; | ||
} | ||
} | ||
@@ -53,3 +61,9 @@ return data; | ||
for (var key in this.$options.asyncComputed || {}) { | ||
this[key] = defaultFor.call(this, this.$options.asyncComputed[key], pluginOptions); | ||
var item = this.$options.asyncComputed[key], | ||
value = generateDefault.call(this, item, pluginOptions); | ||
if ((0, _lazy.isComputedLazy)(item)) { | ||
(0, _lazy.silentSetLazy)(this, key, value); | ||
} else { | ||
this[key] = value; | ||
} | ||
} | ||
@@ -93,3 +107,3 @@ | ||
function getterFor(fn) { | ||
function getterFn(key, fn) { | ||
if (typeof fn === 'function') return fn; | ||
@@ -105,6 +119,16 @@ | ||
} | ||
if ((0, _lazy.isComputedLazy)(fn)) { | ||
var nonLazy = getter; | ||
getter = function lazyGetter() { | ||
if ((0, _lazy.isLazyActive)(this, key)) { | ||
return nonLazy.call(this); | ||
} else { | ||
return (0, _lazy.silentGetLazy)(this, key); | ||
} | ||
}; | ||
} | ||
return getter; | ||
} | ||
function defaultFor(fn, pluginOptions) { | ||
function generateDefault(fn, pluginOptions) { | ||
var defaultValue = null; | ||
@@ -111,0 +135,0 @@ |
{ | ||
"name": "vue-async-computed", | ||
"version": "3.2.1", | ||
"version": "3.3.0-rc1", | ||
"description": "Async computed properties for Vue", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20839
6
176
1