UNPKG

vue-coerce-props

Version:
7 lines (6 loc) 621 B
/** * vue-coerce-props v1.0.0 * (c) 2018 Eduardo San Martin Morote <posva13@gmail.com> * @license MIT */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.VueCoerceProps=t()}(this,function(){"use strict";return{beforeCreate:function(){var e=this.$options.props;e&&(this._$coertions=Object.keys(e).filter(function(t){return e[t].coerce}).map(function(t){return[t,e[t].coerce]}))},computed:{$coerced:function(){var e=this;return this._$coertions.reduce(function(t,o){var n=o[0],r=o[1];return t[n]=r.call(e,e.$props[n]),t},{})}}}});