研发专用
Methods
(static) elementUnique(array, field, value) → {*}
Ec.elementUnique
1. 基本介绍
在输入数组中查找field = value的唯一元素对象。
Parameters:
| Name | Type | Description |
|---|---|---|
array |
Array | 输入数组信息 |
field |
String | 查找的字段信息 |
value |
执行过滤和匹配的 |
Returns:
返回查找的唯一元素
- Type
- *
(static) elementZip(source, target, merged) → {Object}
- Deprecated:
- Yes
Ec.elementZip
(后期将升级或被废弃)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
source |
Array | 原数组 |
|
target |
Array | 目标数组 |
|
merged |
Boolean |
false
|
执行合并的模式,覆盖和追加 |
Returns:
返回最终的数据信息
- Type
- Object
(static) executeBody(commanders, Executor)
Ec.executeBody
执行命令的主方法
Parameters:
| Name | Type | Description |
|---|---|---|
commanders |
Array | 指令集 |
Executor |
Object | 指令执行集 |
(static) executeHeader(app)
Ec.executeHeader
执行命令时打印头信息
Parameters:
| Name | Type | Description |
|---|---|---|
app |
String | 应用程序名 |
(static) executeInput(required, optional) → {Object}
Ec.executeInput
1. 基本介绍
const actual = Ec.executeInput(
[],
[
['-n', '--number', 20]
]
);
2. 参数列表
2.1. required 参数格式:
// 索引1:短参数
// 索引2:长参数
["-h", "--help"]
2.2. optional 参数格式:
// 索引1:短参数
// 索引2:长参数
// 索引3:参数的默认值
['-n', '--number', 20]
Parameters:
| Name | Type | Description |
|---|---|---|
required |
Array | 必须参数设置 |
optional |
Array | 可选参数设置 |
Returns:
生成最终的参数集
- Type
- Object
(static) itArray(array, executor) → {Array}
Ec.itArray
1. 基本介绍
迭代输入的数组,然后执行函数executor,该函数签名如下,它有两个参数:
function(item, index){
}
2. 内置参数
| 参数 | 类型 | 含义 |
|---|---|---|
| item | Object/<Any> |
每一个数组中的元素,任意类型。 |
| index | Number | 该元素在数组中的索引值。 |
Parameters:
| Name | Type | Description |
|---|---|---|
array |
Array | 被迭代的数组 |
executor |
function | 第二参数,必须是一个标准的JavaScript函数 |
Returns:
返回执行完成后的数组
- Type
- Array
(static) parseArgs(ensure) → {Object}
Ec.parseArgs
Parameters:
| Name | Type | Description |
|---|---|---|
ensure |
Number | 参数允许的长度解析,如果长度不合法,则直接退出 |
Returns:
解析成功后的数据信息
- Type
- Object
(static) parseZero(path, fileTypes) → {Any}
Ec.parseZero
1. 基本介绍
解析路径中的特殊文件,文件后缀使用.zero,作为当前工具的核心配置数据,文件内容通常如下(UTF-8方式读取内容):
PREFIX;
<Content>
此处PREFIX则是第二参数,表示不同的文件类型,不同文件类型的解析方式有所区别。
2. 文件类型
| 前缀 | 含义 |
|---|---|
P; |
属性文件专用集,用于描述基础属性文件内容。 |
KV; |
P;的不换行模式,直接以,为每一个键值对的匹配项,去\n换行符过后统一解析,不支持ENUM枚举信息。 |
R; |
关系专用解析文件,可解析关系数据文件(后期可增强)。 |
A; |
命令解析专用,表格解析器,解析以\t为分隔符的表格,然后解析尾部optionX部分为配置选项。 |
UI; |
Jsx文件专用解析器,根据文件模板解析数据。 |
J; |
Java文件专用解析器,解析Java源代码文件数据专用。 |
Parameters:
| Name | Type | Description |
|---|---|---|
path |
String | 解析文件的路径 |
fileTypes |
Array | 文件前缀类型 |
Returns:
最终解析出来的数据内容
- Type
- Any