amis-formula 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -196,65 +196,639 @@ export declare class Evaluator {
196
196
  identifier: string;
197
197
  args: Array<any>;
198
198
  }): any;
199
+ /**
200
+ * 示例:IF(A, B, C)
201
+ *
202
+ * 如果满足条件A,则返回B,否则返回C,支持多层嵌套IF函数。
203
+ *
204
+ * 也可以用表达式如:A ? B : C
205
+ *
206
+ * @example IF(condition, consequent, alternate)
207
+ * @param {expression} condition - 条件表达式.
208
+ * @param {any} consequent 条件判断通过的返回结果
209
+ * @param {any} alternate 条件判断不通过的返回结果
210
+ * @namespace 逻辑函数
211
+ *
212
+ * @returns {any} 根据条件返回不同的结果
213
+ */
199
214
  fnIF(condition: () => any, trueValue: () => any, falseValue: () => any): any;
215
+ /**
216
+ * 条件全部符合,返回 true,否则返回 false
217
+ *
218
+ * 示例:AND(语文成绩>80, 数学成绩>80)
219
+ *
220
+ * 语文成绩和数学成绩都大于 80,则返回 true,否则返回 false
221
+ *
222
+ * 也可以直接用表达式如:语文成绩>80 && 数学成绩>80
223
+ *
224
+ * @example AND(expression1, expression2, ...expressionN)
225
+ * @param {...expression} conditions - 条件表达式.
226
+ * @namespace 逻辑函数
227
+ *
228
+ * @returns {boolean}
229
+ */
200
230
  fnAND(...condtions: Array<() => any>): boolean;
231
+ /**
232
+ * 条件任意一个满足条件,返回 true,否则返回 false
233
+ *
234
+ * 示例:OR(语文成绩>80, 数学成绩>80)
235
+ *
236
+ * 语文成绩和数学成绩任意一个大于 80,则返回 true,否则返回 false
237
+ *
238
+ * 也可以直接用表达式如:语文成绩>80 || 数学成绩>80
239
+ *
240
+ * @example OR(expression1, expression2, ...expressionN)
241
+ * @param {...expression} conditions - 条件表达式.
242
+ * @namespace 逻辑函数
243
+ *
244
+ * @returns {boolean}
245
+ */
201
246
  fnOR(...condtions: Array<() => any>): boolean;
247
+ /**
248
+ * 异或处理,两个表达式同时为「真」,或者同时为「假」,则结果返回为「真」
249
+ *
250
+ * @example XOR(condition1, condition2)
251
+ * @param {expression} condition1 - 条件表达式1
252
+ * @param {expression} condition2 - 条件表达式2
253
+ * @namespace 逻辑函数
254
+ *
255
+ * @returns {boolean}
256
+ */
202
257
  fnXOR(c1: () => any, c2: () => any): boolean;
258
+ /**
259
+ * 判断函数集合,相当于多个 else if 合并成一个。
260
+ *
261
+ * 示例:IFS(语文成绩 > 80, "优秀", 语文成绩 > 60, "良", "继续努力")
262
+ *
263
+ * 如果语文成绩大于 80,则返回优秀,否则判断大于 60 分,则返回良,否则返回继续努力。
264
+ *
265
+ * @example IFS(condition1, result1, condition2, result2,...conditionN, resultN)
266
+ * @param {...any} args - 条件,返回值集合
267
+ * @returns {any} 返回第一个满足条件的结果,没有命中的返回 false。
268
+ */
203
269
  fnIFS(...args: Array<() => any>): any;
270
+ /**
271
+ * 返回传入数字的绝对值
272
+ *
273
+ * @example ABS(num)
274
+ * @param {number} num - 数值
275
+ * @namespace 数学函数
276
+ *
277
+ * @returns {number} 返回传入数值的绝对值
278
+ */
204
279
  fnABS(a: number): number;
280
+ /**
281
+ * 获取最大值
282
+ *
283
+ * @example MAX(num1, num2, ...numN)
284
+ * @param {...number} num - 数值
285
+ * @namespace 数学函数
286
+ *
287
+ * @returns {number} 返回所有传入值中最大的那个
288
+ */
205
289
  fnMAX(...args: Array<any>): any;
290
+ /**
291
+ * 获取最小值
292
+ *
293
+ * @example MIN(num1, num2, ...numN)
294
+ * @param {...number} num - 数值
295
+ * @namespace 数学函数
296
+ *
297
+ * @returns {number} 返回所有传入值中最小的那个
298
+ */
206
299
  fnMIN(...args: Array<number>): any;
300
+ /**
301
+ * 求和
302
+ *
303
+ * @example SUM(num1, num2, ...numN)
304
+ * @param {...number} num - 数值
305
+ * @namespace 数学函数
306
+ *
307
+ * @returns {number} 返回所有传入数值的总和
308
+ */
207
309
  fnSUM(...args: Array<number>): any;
310
+ /**
311
+ * 将数值向下取整为最接近的整数
312
+ *
313
+ * @example INT(num)
314
+ * @param {number} num - 数值
315
+ * @namespace 数学函数
316
+ *
317
+ * @returns {number} 返回数值对应的整形
318
+ */
208
319
  fnINT(n: number): number;
320
+ /**
321
+ * 返回两数相除的余数,参数 number 是被除数,divisor 是除数
322
+ *
323
+ * @example MOD(num, divisor)
324
+ * @param {number} num - 被除数
325
+ * @param {number} divisor - 除数
326
+ * @namespace 数学函数
327
+ *
328
+ * @returns {number} 返回两数相除的余数
329
+ */
209
330
  fnMOD(a: number, b: number): number;
331
+ /**
332
+ * 圆周率 3.1415...
333
+ *
334
+ * @example PI()
335
+ * @namespace 数学函数
336
+ *
337
+ * @returns {number} 返回圆周率数值
338
+ */
210
339
  fnPI(): number;
340
+ /**
341
+ * 将数字四舍五入到指定的位数,可以设置小数位。
342
+ *
343
+ * @example ROUND(num[, numDigits = 2])
344
+ * @param {number} num - 要处理的数字
345
+ * @param {number} numDigits - 小数位数
346
+ * @namespace 数学函数
347
+ *
348
+ * @returns {number} 返回传入数值四舍五入后的结果
349
+ */
211
350
  fnROUND(a: number, b: number): number;
351
+ /**
352
+ * 将数字向下取整到指定的位数,可以设置小数位。
353
+ *
354
+ * @example FLOOR(num[, numDigits=2])
355
+ * @param {number} num - 要处理的数字
356
+ * @param {number} numDigits - 小数位数
357
+ * @namespace 数学函数
358
+ *
359
+ * @returns {number} 返回传入数值向下取整后的结果
360
+ */
212
361
  fnFLOOR(a: number, b: number): number;
362
+ /**
363
+ * 将数字向上取整到指定的位数,可以设置小数位。
364
+ *
365
+ * @example CEIL(num[, numDigits=2])
366
+ * @param {number} num - 要处理的数字
367
+ * @param {number} numDigits - 小数位数
368
+ * @namespace 数学函数
369
+ *
370
+ * @returns {number} 返回传入数值向上取整后的结果
371
+ */
213
372
  fnCEIL(a: number, b: number): number;
373
+ /**
374
+ * 开平方,参数 number 为非负数
375
+ *
376
+ * @example SQRT(num)
377
+ * @param {number} num - 要处理的数字
378
+ * @namespace 数学函数
379
+ *
380
+ * @returns {number} 返回开平方的结果
381
+ */
214
382
  fnSQRT(n: number): number;
383
+ /**
384
+ * 返回所有参数的平均值
385
+ *
386
+ * @example AVG(num1, num2, ...numN)
387
+ * @param {...number} num - 要处理的数字
388
+ * @namespace 数学函数
389
+ *
390
+ * @returns {number} 返回所有数值的平均值
391
+ */
215
392
  fnAVG(...args: Array<any>): number;
393
+ /**
394
+ * 将数值转为中文大写金额
395
+ *
396
+ * @example UPPERMONEY(num)
397
+ * @param {number} num - 要处理的数字
398
+ * @namespace 数学函数
399
+ *
400
+ * @returns {string} 返回数值中文大写字符
401
+ */
216
402
  fnUPPERMONEY(n: number): string;
403
+ /**
404
+ * 返回大于等于 0 且小于 1 的均匀分布随机实数。每一次触发计算都会变化。
405
+ *
406
+ * 示例:`RAND()*100`
407
+ *
408
+ * 返回 0-100 之间的随机数
409
+ *
410
+ * @example RAND()
411
+ * @namespace 数学函数
412
+ *
413
+ * @returns {number} 返回随机数
414
+ */
217
415
  fnRAND(): number;
218
416
  normalizeText(raw: any): string;
417
+ /**
418
+ * 返回传入文本左侧的指定长度字符串。
419
+ *
420
+ * @example LEFT(text, len)
421
+ * @param {string} text - 要处理的文本
422
+ * @param {number} len - 要处理的长度
423
+ * @namespace 文本函数
424
+ *
425
+ * @returns {string} 对应字符串
426
+ */
219
427
  fnLEFT(text: string, len: number): string;
428
+ /**
429
+ * 返回传入文本右侧的指定长度字符串。
430
+ *
431
+ * @example RIGHT(text, len)
432
+ * @param {string} text - 要处理的文本
433
+ * @param {number} len - 要处理的长度
434
+ * @namespace 文本函数
435
+ *
436
+ * @returns {string} 对应字符串
437
+ */
220
438
  fnRIGHT(text: string, len: number): string;
439
+ /**
440
+ * 计算文本的长度
441
+ *
442
+ * @example LEN(text)
443
+ * @param {string} text - 要处理的文本
444
+ * @namespace 文本函数
445
+ *
446
+ * @returns {number} 长度
447
+ */
221
448
  fnLEN(text: string): number;
449
+ /**
450
+ * 计算文本集合中所有文本的长度
451
+ *
452
+ * @example LENGTH(textArr)
453
+ * @param {string[]} textArr - 要处理的文本集合
454
+ * @namespace 文本函数
455
+ *
456
+ * @returns {number[]} 返回长度集合
457
+ */
222
458
  fnLENGTH(...args: any[]): any;
459
+ /**
460
+ * 判断文本是否为空
461
+ *
462
+ * @example ISEMPTY(text)
463
+ * @param {string} text - 要处理的文本
464
+ * @namespace 文本函数
465
+ *
466
+ * @returns {boolean} 返回判断结果
467
+ */
223
468
  fnISEMPTY(text: string): boolean;
469
+ /**
470
+ * 将多个传入值连接成文本
471
+ *
472
+ * @example CONCATENATE(text1, text2, ...textN)
473
+ * @param {...string} text - 文本集合
474
+ * @namespace 文本函数
475
+ *
476
+ * @returns {string} 返回连接后的文本
477
+ */
224
478
  fnCONCATENATE(...args: Array<any>): string;
479
+ /**
480
+ * 返回计算机字符集的数字代码所对应的字符。
481
+ *
482
+ * `CHAR(97)` 等价于 "a"
483
+ *
484
+ * @example CHAR(code)
485
+ * @param {number} code - 编码值
486
+ * @namespace 文本函数
487
+ *
488
+ * @returns {string} 返回指定位置的字符
489
+ */
225
490
  fnCHAR(code: number): string;
491
+ /**
492
+ * 将传入文本转成小写
493
+ *
494
+ * @example LOWER(text)
495
+ * @param {string} text - 文本
496
+ * @namespace 文本函数
497
+ *
498
+ * @returns {string} 返回结果文本
499
+ */
226
500
  fnLOWER(text: string): string;
501
+ /**
502
+ * 将传入文本转成大写
503
+ *
504
+ * @example UPPER(text)
505
+ * @param {string} text - 文本
506
+ * @namespace 文本函数
507
+ *
508
+ * @returns {string} 返回结果文本
509
+ */
227
510
  fnUPPER(text: string): string;
511
+ /**
512
+ * 将文本根据指定片段分割成数组
513
+ *
514
+ * 示例:`SPLIT("a,b,c", ",")`
515
+ *
516
+ * 返回 `["a", "b", "c"]`
517
+ *
518
+ * @example SPLIT(text, ',')
519
+ * @param {string} text - 文本
520
+ * @param {string} delimiter - 文本片段
521
+ * @namespace 文本函数
522
+ *
523
+ * @returns {Array<string>} 返回文本集
524
+ */
228
525
  fnSPLIT(text: string, sep?: string): string[];
526
+ /**
527
+ * 将文本去除前后空格
528
+ *
529
+ * @example TRIM(text)
530
+ * @param {string} text - 文本
531
+ * @namespace 文本函数
532
+ *
533
+ * @returns {string} 返回处理后的文本
534
+ */
229
535
  fnTRIM(text: string): string;
536
+ /**
537
+ * 判断字符串(text)是否以特定字符串(startString)开始,是则返回 True,否则返回 False
538
+ *
539
+ * @example STARTSWITH(text, '片段')
540
+ * @param {string} text - 文本
541
+ * @param {string} startString - 起始文本
542
+ * @namespace 文本函数
543
+ *
544
+ * @returns {string} 返回判断结果
545
+ */
230
546
  fnSTARTSWITH(text: string, search: string): boolean;
547
+ /**
548
+ * 判断参数 1 中的文本是否包含参数 2 中的文本。
549
+ *
550
+ * @example CONTAINS(text, searchText)
551
+ * @param {string} text - 文本
552
+ * @param {string} searchText - 搜索文本
553
+ * @namespace 文本函数
554
+ *
555
+ * @returns {string} 返回判断结果
556
+ */
231
557
  fnCONTAINS(text: string, search: string): boolean;
558
+ /**
559
+ * 对文本进行全量替换。
560
+ *
561
+ * @example REPLACE(text, search, replace)
562
+ * @param {string} text - 要处理的文本
563
+ * @param {string} search - 要被替换的文本
564
+ * @param {string} replace - 要替换的文本
565
+ * @namespace 文本函数
566
+ *
567
+ * @returns {string} 返回处理结果
568
+ */
232
569
  fnREPLACE(text: string, search: string, replace: string): string;
570
+ /**
571
+ * 对文本进行搜索,返回命中的位置
572
+ *
573
+ * @example SEARCH(text, search, 0)
574
+ * @param {string} text - 要处理的文本
575
+ * @param {string} search - 用来搜索的文本
576
+ * @param {number} start - 起始位置
577
+ * @namespace 文本函数
578
+ *
579
+ * @returns {number} 返回命中的位置
580
+ */
233
581
  fnSEARCH(text: string, search: string, start?: number): number;
582
+ /**
583
+ * 返回文本字符串中从指定位置开始的特定数目的字符
584
+ *
585
+ * @example MID(text, from, len)
586
+ * @param {string} text - 要处理的文本
587
+ * @param {number} from - 起始位置
588
+ * @param {number} len - 处理长度
589
+ * @namespace 文本函数
590
+ *
591
+ * @returns {number} 返回命中的位置
592
+ */
234
593
  fnMID(text: string, from: number, len: number): string;
594
+ /**
595
+ * 创建日期对象,可以通过特定格式的字符串,或者数值。
596
+ *
597
+ * 需要注意的是,其中月份的数值是从0开始的,也就是说,
598
+ * 如果是12月份,你应该传入数值11。
599
+ *
600
+ * @example DATE(2021, 11, 6, 8, 20, 0)
601
+ * @example DATE('2021-12-06 08:20:00')
602
+ * @namespace 日期函数
603
+ *
604
+ * @returns {Date} 返回日期对象
605
+ */
235
606
  fnDATE(year: number, month: number, day: number, hour: number, minute: number, second: number): Date;
607
+ /**
608
+ * 返回时间的时间戳
609
+ *
610
+ * @example TIMESTAMP(date[, format = "X"])
611
+ * @namespace 日期函数
612
+ * @param {date} date 日期对象
613
+ * @param {string} format 时间戳格式,带毫秒传入 'x'。默认为 'X' 不带毫秒的。
614
+ *
615
+ * @returns {number} 返回时间戳
616
+ */
236
617
  fnTIMESTAMP(date: Date, format?: 'x' | 'X'): number;
618
+ /**
619
+ * 返回今天的日期
620
+ *
621
+ * @example TODAY()
622
+ * @namespace 日期函数
623
+ *
624
+ * @returns {number} 返回日期
625
+ */
237
626
  fnTODAY(): Date;
627
+ /**
628
+ * 返回现在的日期
629
+ *
630
+ * @example NOW()
631
+ * @namespace 日期函数
632
+ *
633
+ * @returns {number} 返回日期
634
+ */
238
635
  fnNOW(): Date;
636
+ /**
637
+ * 将日期转成日期字符串
638
+ *
639
+ * @example DATETOSTR(date[, format="YYYY-MM-DD HH:mm:ss"])
640
+ * @namespace 日期函数
641
+ * @param {date} date 日期对象
642
+ * @param {string} format 日期格式,默认为 "YYYY-MM-DD HH:mm:ss"
643
+ *
644
+ * @returns {number} 返回日期字符串
645
+ */
239
646
  fnDATETOSTR(date: Date, format?: string): string;
647
+ /**
648
+ * 返回日期的指定范围的开端
649
+ *
650
+ * @namespace 日期函数
651
+ * @example STARTOF(date[unit = "day"])
652
+ * @param {date} date 日期对象
653
+ * @param {string} unit 比如可以传入 'day'、'month'、'year' 或者 `week` 等等
654
+ * @returns {date} 新的日期对象
655
+ */
240
656
  fnSTARTOF(date: Date, unit?: any): Date;
657
+ /**
658
+ * 返回日期的指定范围的末尾
659
+ * @namespace 日期函数
660
+ * @example ENDOF(date[unit = "day"])
661
+ * @param {date} date 日期对象
662
+ * @param {string} unit 比如可以传入 'day'、'month'、'year' 或者 `week` 等等
663
+ * @returns {date} 新的日期对象
664
+ */
241
665
  fnENDOF(date: Date, unit?: any): Date;
242
666
  normalizeDate(raw: any): Date;
667
+ /**
668
+ * 返回日期的年份
669
+ * @namespace 日期函数
670
+ * @example YEAR(date)
671
+ * @param {date} date 日期对象
672
+ * @returns {number} 返回数值
673
+ */
243
674
  fnYEAR(date: Date): number;
675
+ /**
676
+ * 返回日期的月份,这里就是自然月份。
677
+ *
678
+ * @namespace 日期函数
679
+ * @example MONTH(date)
680
+ * @param {date} date 日期对象
681
+ * @returns {number} 返回数值
682
+ */
244
683
  fnMONTH(date: Date): number;
684
+ /**
685
+ * 返回日期的天
686
+ * @namespace 日期函数
687
+ * @example DAY(date)
688
+ * @param {date} date 日期对象
689
+ * @returns {number} 返回数值
690
+ */
245
691
  fnDAY(date: Date): number;
692
+ /**
693
+ * 返回日期的小时
694
+ * @param {date} date 日期对象
695
+ * @namespace 日期函数
696
+ * @example HOUR(date)
697
+ * @returns {number} 返回数值
698
+ */
246
699
  fnHOUR(date: Date): number;
247
- fnHMINUTE(date: Date): number;
700
+ /**
701
+ * 返回日期的分
702
+ * @param {date} date 日期对象
703
+ * @namespace 日期函数
704
+ * @example MINUTE(date)
705
+ * @returns {number} 返回数值
706
+ */
707
+ fnMINUTE(date: Date): number;
708
+ /**
709
+ * 返回日期的秒
710
+ * @param {date} date 日期对象
711
+ * @namespace 日期函数
712
+ * @example SECOND(date)
713
+ * @returns {number} 返回数值
714
+ */
248
715
  fnSECOND(date: Date): number;
716
+ /**
717
+ * 返回两个日期相差多少年
718
+ * @param {date} endDate 日期对象
719
+ * @param {date} startDate 日期对象
720
+ * @namespace 日期函数
721
+ * @example YEARS(endDate, startDate)
722
+ * @returns {number} 返回数值
723
+ */
249
724
  fnYEARS(endDate: Date, startDate: Date): number;
725
+ /**
726
+ * 返回两个日期相差多少分钟
727
+ * @param {date} endDate 日期对象
728
+ * @param {date} startDate 日期对象
729
+ * @namespace 日期函数
730
+ * @example MINUTES(endDate, startDate)
731
+ * @returns {number} 返回数值
732
+ */
250
733
  fnMINUTES(endDate: Date, startDate: Date): number;
734
+ /**
735
+ * 返回两个日期相差多少天
736
+ * @param {date} endDate 日期对象
737
+ * @param {date} startDate 日期对象
738
+ * @namespace 日期函数
739
+ * @example DAYS(endDate, startDate)
740
+ * @returns {number} 返回数值
741
+ */
251
742
  fnDAYS(endDate: Date, startDate: Date): number;
743
+ /**
744
+ * 返回两个日期相差多少小时
745
+ * @param {date} endDate 日期对象
746
+ * @param {date} startDate 日期对象
747
+ * @namespace 日期函数
748
+ * @example HOURS(endDate, startDate)
749
+ * @returns {number} 返回数值
750
+ */
252
751
  fnHOURS(endDate: Date, startDate: Date): number;
752
+ /**
753
+ * 修改日期,对日期进行加减天、月份、年等操作
754
+ *
755
+ * 示例:
756
+ *
757
+ * DATEMODIFY(A, -2, 'month')
758
+ *
759
+ * 对日期 A 进行往前减2月的操作。
760
+ *
761
+ * @param {date} date 日期对象
762
+ * @param {number} num 数值
763
+ * @param {string} unit 单位:支持年、月、天等等
764
+ * @namespace 日期函数
765
+ * @example DATEMODIFY(date, 2, 'days')
766
+ * @returns {date} 返回日期对象
767
+ */
253
768
  fnDATEMODIFY(date: Date, num: number, format: any): Date;
769
+ /**
770
+ * 将字符日期转成日期对象,可以指定日期格式。
771
+ *
772
+ * 示例:STRTODATE('2021/12/6', 'YYYY/MM/DD')
773
+ *
774
+ * @param {string} value 日期字符
775
+ * @param {string} format 日期格式
776
+ * @namespace 日期函数
777
+ * @example STRTODATE(value[, format=""])
778
+ * @returns {date} 返回日期对象
779
+ */
254
780
  fnSTRTODATE(value: any, format?: string): Date;
781
+ /**
782
+ * 判断两个日期,是否第一个日期在第二个日期的前面
783
+ *
784
+ * @param {date} a 第一个日期
785
+ * @param {date} b 第二个日期
786
+ * @param {string} unit 单位,默认是 'day', 即之比较到天
787
+ * @namespace 日期函数
788
+ * @example ISBEFORE(a, b)
789
+ * @returns {boolean}} 返回判断结果
790
+ */
255
791
  fnISBEFORE(a: Date, b: Date, unit?: any): boolean;
792
+ /**
793
+ * 判断两个日期,是否第一个日期在第二个日期的后面
794
+ *
795
+ * @param {date} a 第一个日期
796
+ * @param {date} b 第二个日期
797
+ * @param {string} unit 单位,默认是 'day', 即之比较到天
798
+ * @namespace 日期函数
799
+ * @example ISAFTER(a, b)
800
+ * @returns {boolean}} 返回判断结果
801
+ */
256
802
  fnISAFTER(a: Date, b: Date, unit?: any): boolean;
803
+ /**
804
+ * 判断两个日期,是否第一个日期在第二个日期的前面或者相等
805
+ *
806
+ * @param {date} a 第一个日期
807
+ * @param {date} b 第二个日期
808
+ * @param {string} unit 单位,默认是 'day', 即之比较到天
809
+ * @namespace 日期函数
810
+ * @example ISSAMEORBEFORE(a, b)
811
+ * @returns {boolean}} 返回判断结果
812
+ */
257
813
  fnISSAMEORBEFORE(a: Date, b: Date, unit?: any): boolean;
814
+ /**
815
+ * 判断两个日期,是否第一个日期在第二个日期的后面或者相等
816
+ *
817
+ * @param {date} a 第一个日期
818
+ * @param {date} b 第二个日期
819
+ * @param {string} unit 单位,默认是 'day', 即之比较到天
820
+ * @namespace 日期函数
821
+ * @example ISSAMEORAFTER(a, b)
822
+ * @returns {boolean}} 返回判断结果
823
+ */
258
824
  fnISSAMEORAFTER(a: Date, b: Date, unit?: any): boolean;
825
+ /**
826
+ * 返回数组的长度
827
+ *
828
+ * @param {Array<any>} arr 数组
829
+ * @namespace 其他
830
+ * @example COUNT(arr)
831
+ * @returns {boolean} 返回结果
832
+ */
259
833
  fnCOUNT(value: any): number;
260
834
  }