doc: 完善公式文档说明 (#11239)

This commit is contained in:
liaoxuezhi 2024-11-21 16:11:51 +08:00 committed by GitHub
parent d938e410a9
commit 6f41563f51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -679,7 +679,7 @@ export class Evaluator {
/**
*
*
* @example MAX(num1, num2, ...numN)
* @example MAX(num1, num2, ...numN) or MAX([num1, num2, ...numN])
* @param {...number} num -
* @namespace
*
@ -696,7 +696,7 @@ export class Evaluator {
/**
*
*
* @example MIN(num1, num2, ...numN)
* @example MIN(num1, num2, ...numN) or MIN([num1, num2, ...numN])
* @param {...number} num -
* @namespace
*
@ -713,7 +713,7 @@ export class Evaluator {
/**
*
*
* @example SUM(num1, num2, ...numN)
* @example SUM(num1, num2, ...numN) or SUM([num1, num2, ...numN])
* @param {...number} num -
* @namespace
*
@ -848,7 +848,7 @@ export class Evaluator {
/**
*
*
* @example AVG(num1, num2, ...numN)
* @example AVG(num1, num2, ...numN) or AVG([num1, num2, ...numN])
* @param {...number} num -
* @namespace
*
@ -1057,7 +1057,7 @@ export class Evaluator {
return base;
}
return Math.pow(base, exponent);
return Math.pow(this.formatNumber(base), this.formatNumber(exponent));
}
// 文本函数
@ -1124,7 +1124,7 @@ export class Evaluator {
* @returns {number[]}
*/
fnLENGTH(...args: any[]) {
return this.fnLEN.call(this, args);
return this.fnLEN.apply(this, args);
}
/**
@ -1150,7 +1150,7 @@ export class Evaluator {
* @returns {string}
*/
fnCONCATENATE(...args: Array<any>) {
return args.join('');
return args.map(this.normalizeText).join('');
}
/**
@ -1378,7 +1378,7 @@ export class Evaluator {
* @param {string} startString -
* @namespace
*
* @returns {string}
* @returns {boolean}
*/
fnSTARTSWITH(text: string, search: string) {
search = this.normalizeText(search);
@ -1398,7 +1398,7 @@ export class Evaluator {
* @param {string} endString -
* @namespace
*
* @returns {string}
* @returns {boolean}
*/
fnENDSWITH(text: string, search: string) {
search = this.normalizeText(search);
@ -1418,7 +1418,7 @@ export class Evaluator {
* @param {string} searchText -
* @namespace
*
* @returns {string}
* @returns {boolean}
*/
fnCONTAINS(text: string, search: string) {
search = this.normalizeText(search);
@ -1501,13 +1501,17 @@ export class Evaluator {
/**
*
*
* `MID("amis.baidu.com", 6, 3)`
*
* `aid`
*
* @example MID(text, from, len)
* @param {string} text -
* @param {number} from -
* @param {number} len -
* @namespace
*
* @returns {number}
* @returns {string}
*/
fnMID(text: string, from: number, len: number) {
text = this.normalizeText(text);
@ -1521,7 +1525,7 @@ export class Evaluator {
*
* `/home/amis/a.json`
*
* a.json`
* `a.json`
*
* @example BASENAME(text)
* @param {string} text -
@ -1741,7 +1745,7 @@ export class Evaluator {
* @param {date} date
* @param {string} unit 'day''month''year' `week`
* @param {string} format
* @returns {date}
* @returns {date | string} , format
*/
fnSTARTOF(date: Date, unit?: any, format?: string) {
const md = moment(this.normalizeDate(date)).startOf(unit || 'day');
@ -1756,7 +1760,7 @@ export class Evaluator {
* @param {date} date
* @param {string} unit 'day''month''year' `week`
* @param {string} format
* @returns {date}
* @returns {date | string} , format
*/
fnENDOF(date: Date, unit?: any, format?: string) {
const md = moment(this.normalizeDate(date)).endOf(unit || 'day');
@ -2063,7 +2067,7 @@ export class Evaluator {
* @param {Array<any>} arr
* @namespace
* @example COUNT(arr)
* @returns {boolean}
* @returns {number}
*/
fnCOUNT(value: any) {
return Array.isArray(value) ? value.length : value ? 1 : 0;
@ -2072,11 +2076,17 @@ export class Evaluator {
/**
* 使
*
*
*
*
*
* ARRAYMAP([1, 2, 3], item => item + 1) [2, 3, 4]
*
* @param {Array<any>} arr
* @param {Function<any>} iterator
* @namespace
* @example ARRAYMAP(arr, item => item)
* @returns {boolean}
* @returns {Array<any>}
*/
fnARRAYMAP(value: any, iterator: any) {
if (!iterator || iterator.type !== 'anonymous_function') {
@ -2092,11 +2102,15 @@ export class Evaluator {
* 使
* false
*
*
*
* ARRAYFILTER([1, 2, 3], item => item > 1) [2, 3]
*
* @param {Array<any>} arr
* @param {Function<any>} iterator
* @namespace
* @example ARRAYFILTER(arr, item => item)
* @returns {boolean}
* @returns {Array<any>}
*/
fnARRAYFILTER(value: any, iterator: any) {
if (!iterator || iterator.type !== 'anonymous_function') {
@ -2259,7 +2273,7 @@ export class Evaluator {
* @param { String} separator
* @namespace
* @example JOIN(arr, string)
* @returns {String}
* @returns {string}
*/
fnJOIN(arr: any[], separator = '') {
if (Array.isArray(arr)) {
@ -2293,7 +2307,7 @@ export class Evaluator {
*
*
*
* UNIQ([{a: '1'}, {b: '2'}, {a: '1'}] 'id')
* UNIQ([{a: '1'}, {b: '2'}, {a: '1'}]) [{a: '1'}, {b: '2'}]
*
* @param {Array<any>} arr
* @param {string} field