* 格式化提示信息模板
(source, params)
| 324 | * 格式化提示信息模板 |
| 325 | */ |
| 326 | formatTpl(source, params) { |
| 327 | const that = this |
| 328 | if (arguments.length === 1) { |
| 329 | return function() { |
| 330 | let args = Array.from(arguments) |
| 331 | args.unshift(source) |
| 332 | return that.formatTpl.apply(this, args) |
| 333 | } |
| 334 | } |
| 335 | if (params === undefined) { |
| 336 | return source |
| 337 | } |
| 338 | if (arguments.length > 2 && params.constructor !== Array) { |
| 339 | params = Array.from(arguments).slice(1) |
| 340 | } |
| 341 | if (params.constructor !== Array) { |
| 342 | params = [params] |
| 343 | } |
| 344 | params.forEach(function(n, i) { |
| 345 | source = source.replace(new RegExp("\\{" + i + "\\}", "g"), function() { |
| 346 | return n |
| 347 | }) |
| 348 | }) |
| 349 | return source |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * 判断规则依赖是否存在 |
nothing calls this directly
no outgoing calls
no test coverage detected