| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/@intlify/vue-i18n-extensions/src/ |
Upload File : |
const parser = require('@babel/parser')
function warn (msg, err) {
if (typeof console !== 'undefined') {
console.warn('[vue-i18n-extensions] ' + msg)
/* istanbul ignore if */
if (err) {
console.warn(err.stack)
}
}
}
const toString = Object.prototype.toString
const OBJECT_STRING = '[object Object]'
function isPlainObject (obj) {
return toString.call(obj) === OBJECT_STRING
}
function addProp (el, name, value) {
(el.props || (el.props = [])).push({ name, value })
}
function getAttr (el, name) {
return el.attrsMap[name]
}
function removeAttr (el, name) {
if ((el.attrsMap[name]) !== null) {
const list = el.attrsList
for (let i = 0, l = list.length; i < l; i++) {
if (list[i].name === name) {
list.splice(i, 1)
break
}
}
}
}
function evaluateValue (expression) {
const ret = { status: 'ng', value: undefined }
try {
const ast = parser.parse(`const a = ${expression.trim()}`)
const node = ast.program.body[0].declarations[0].init
if (node.type === 'StringLiteral' || node.type === 'ObjectExpression') {
const val = (new Function(`return ${expression.trim()}`))()
ret.status = 'ok'
ret.value = val
}
} catch (e) { }
return ret
}
module.exports = {
warn,
isPlainObject,
addProp,
getAttr,
removeAttr,
evaluateValue
}