feat:formula补充一些数组函数

This commit is contained in:
lvxiaojiao 2023-02-17 13:20:22 +08:00
parent 4131d448d6
commit 70149e7829
3 changed files with 8 additions and 3 deletions

View File

@ -1008,6 +1008,7 @@ UNIQ([{a: '1'}, {b: '2'}, {a: '1'}] 'id')
* `obj:any` 对象或数组
* `path:string` 路径
* `defaultValue:any` 如果解析不到则返回该值
返回:`any` 结果
@ -1017,7 +1018,6 @@ UNIQ([{a: '1'}, {b: '2'}, {a: '1'}] 'id')
GET([0, 2, {name: 'amis', age: 18}], 1) 得到 2
GET([0, 2, {name: 'amis', age: 18}], '2.name') 得到 'amis'
GET([0, 2, {name: 'amis', age: 18}], '[2].name') 得到 'amis'
GET({arr: [{name: 'amis', age: 18}]}, 'arr[0].name') 得到 'amis'
GET({arr: [{name: 'amis', age: 18}]}, 'arr.0.name') 得到 'amis'
GET({arr: [{name: 'amis', age: 18}]}, 'arr.1.name', 'not-found') 得到 'not-found'

View File

@ -1615,7 +1615,7 @@ export const doc: {
},
{
name: "GET",
description: "根据对象或者数组的path路径获取值。 如果解析 value 是 undefined 会以 defaultValue 取代\n\n示例\n\nGET([0, 2, {name: 'amis', age: 18}], 1) 得到 2\nGET([0, 2, {name: 'amis', age: 18}], '2.name') 得到 'amis'\nGET([0, 2, {name: 'amis', age: 18}], '[2].name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr[0].name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr.0.name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr.1.name', 'not-found') 得到 'not-found'",
description: "根据对象或者数组的path路径获取值。 如果解析 value 是 undefined 会以 defaultValue 取代\n\n示例\n\nGET([0, 2, {name: 'amis', age: 18}], 1) 得到 2\nGET([0, 2, {name: 'amis', age: 18}], '2.name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr[0].name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr.0.name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr.1.name', 'not-found') 得到 'not-found'",
example: "GET(arr, 2)",
params: [
{
@ -1627,6 +1627,11 @@ export const doc: {
type: "string",
name: "path",
description: "路径"
},
{
type: "any",
name: "defaultValue",
description: "如果解析不到则返回该值"
}
],
returns: {

View File

@ -1962,13 +1962,13 @@ export class Evaluator {
*
* GET([0, 2, {name: 'amis', age: 18}], 1) 2
* GET([0, 2, {name: 'amis', age: 18}], '2.name') 'amis'
* GET([0, 2, {name: 'amis', age: 18}], '[2].name') 'amis'
* GET({arr: [{name: 'amis', age: 18}]}, 'arr[0].name') 'amis'
* GET({arr: [{name: 'amis', age: 18}]}, 'arr.0.name') 'amis'
* GET({arr: [{name: 'amis', age: 18}]}, 'arr.1.name', 'not-found') 'not-found'
*
* @param {any} obj
* @param {string} path
* @param {any} defaultValue
* @namespace
* @example GET(arr, 2)
* @returns {any}