MCPcopy Create free account
hub / github.com/Script-Hub-Org/Script-Hub / parseLoonValue

Function parseLoonValue

Rewrite-Parser.beta.js:3602–3615  ·  view source on GitHub ↗
(_v)

Source from the content-addressed store, hash-verified

3600// "a" 是 "a"
3601// 由于在解析配置是用空格分割各个参数,如果配置的参数中有空格,请使用\x20代替
3602function parseLoonValue(_v) {
3603 let v = _v.replace(/\\x20/g, ' ')
3604 if (/^".*"$/.test(v)) {
3605 // 双引号包裹的肯定是字符串
3606 v = v.replace(/^"(.*?)"$/, '$1')
3607 } else {
3608 try {
3609 v = JSON.parse(v)
3610 } catch (e) {
3611 console.log(`解析 Loon 值 ${v} 失败: ${e}`)
3612 }
3613 }
3614 return v
3615}
3616function done(...args) {
3617 $.log(`⏱ 总耗时:${Math.round(((Date.now() - script_start) / 1000) * 100) / 100} 秒`)
3618 $.done(...args)

Callers 1

Calls 2

parseMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected