调试专用
Methods
(static) error(message)
Ec.error
工具专用日志,ERROR级别,(黄色),消息前缀包含[Zero AI]前缀。
Parameters:
| Name | Type | Description |
|---|---|---|
message |
String | 打印的日志信息。 |
(static) fxContinue(condition, executor)
Ec.fxContinue
1. 基本介绍
专用二分函数,条件满足时执行executor函数,示例代码如:
Fx.fxContinue(0 < items.length, () => {
const prefixes = inflect.pluralize(prefix);
result[prefixes] = items;
});
Parameters:
| Name | Type | Description |
|---|---|---|
condition |
Boolean/Function | 条件或条件函数。 |
executor |
function | 满足条件时的执行函数。 |
Returns:
如果有executor则返回该函数的执行返回值。
(static) fxError(cond, code, …args)
Ec.fxError
1. 基本介绍
参考下边调用代码
// 第一种调用方法:第一参直接是错误代码
Ec.fxError(10001, arg1, arg2);
// 第二种调用方法:第一参是Boolean值,true就输出,第二参是错误代码
const checked = true;
Ec.fxError(checked, 10001, arg1, arg2);
// 第三种调用方法:第一参是Function,执行后结果为true就输出,第二参是错误代码
const fnChecked = () => true;
Ec.fxError(fnChecked, 10001, arg1, arg2);
2. 注意点
- 第一个参数有三种形态,带条件的有两种形态:Boolean/Function,不带条件时直接表示错误代码。
- 第二个参数会受到第一个参数的影响,要么错误代码,要么剩余参数的首参。
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cond |
Boolean/Function/Number | 条件,条件函数和错误代码。 |
|
code |
* | 错误代码或首参。 |
|
args |
* |
<repeatable> |
返回剩余参数信息。 |
(static) fxSorter(input) → {Object}
Ec.fxSorter
「调试专用」对输入对象按属性执行字典序的排列,生成新的对象,方便打印和查看对象基本信息。
Parameters:
| Name | Type | Description |
|---|---|---|
input |
Object | 输入排序之前的对象 |
Returns:
返回排序后的对象
- Type
- Object
(static) info(message)
Ec.info
工具专用日志,INFO级别,(普通日志),消息前缀包含[Zero AI]前缀。
Parameters:
| Name | Type | Description |
|---|---|---|
message |
String | 打印的日志信息。 |
(static) warn(message)
Ec.warn
工具专用日志,INFO级别,(警告日志),消息前缀包含[Zero AI]前缀。
Parameters:
| Name | Type | Description |
|---|---|---|
message |
String | 打印的日志信息。 |