amis-formula 1.3.8 → 1.3.9

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.
package/dist/doc.js CHANGED
@@ -421,6 +421,23 @@ exports.doc = [
421
421
  },
422
422
  namespace: "数学函数"
423
423
  },
424
+ {
425
+ name: "LAST",
426
+ description: "取数据最后一个",
427
+ example: "LAST(array)",
428
+ params: [
429
+ {
430
+ type: "...number",
431
+ name: "arr",
432
+ description: "要处理的数组"
433
+ }
434
+ ],
435
+ returns: {
436
+ type: "any",
437
+ description: "最后一个值"
438
+ },
439
+ namespace: "数学函数"
440
+ },
424
441
  {
425
442
  name: "LEFT",
426
443
  description: "返回传入文本左侧的指定长度字符串。",
@@ -926,6 +943,23 @@ exports.doc = [
926
943
  },
927
944
  namespace: "文本函数"
928
945
  },
946
+ {
947
+ name: "BASENAME",
948
+ description: "返回路径中的文件名\n\n示例:`/home/amis/a.json`\n\n返回:a.json`",
949
+ example: "BASENAME(text)",
950
+ params: [
951
+ {
952
+ type: "string",
953
+ name: "text",
954
+ description: "要处理的文本"
955
+ }
956
+ ],
957
+ returns: {
958
+ type: "string",
959
+ description: "文件名"
960
+ },
961
+ namespace: "文本函数"
962
+ },
929
963
  {
930
964
  name: "DATE",
931
965
  description: "创建日期对象,可以通过特定格式的字符串,或者数值。\n\n需要注意的是,其中月份的数值是从0开始的,也就是说,\n如果是12月份,你应该传入数值11。",
package/dist/doc.md CHANGED
@@ -256,6 +256,16 @@
256
256
 
257
257
  返回 0-100 之间的随机数
258
258
 
259
+ ### LAST
260
+
261
+ 用法:`LAST(array)`
262
+
263
+ * `arr:...number` 要处理的数组
264
+
265
+ 返回:`any` 最后一个值
266
+
267
+ 取数据最后一个
268
+
259
269
  ## 文本函数
260
270
 
261
271
  ### LEFT
@@ -554,6 +564,20 @@
554
564
 
555
565
  返回文本字符串中从指定位置开始的特定数目的字符
556
566
 
567
+ ### BASENAME
568
+
569
+ 用法:`BASENAME(text)`
570
+
571
+ * `text:string` 要处理的文本
572
+
573
+ 返回:`string` 文件名
574
+
575
+ 返回路径中的文件名
576
+
577
+ 示例:`/home/amis/a.json`
578
+
579
+ 返回:a.json`
580
+
557
581
  ## 日期函数
558
582
 
559
583
  ### DATE
@@ -459,6 +459,16 @@ export declare class Evaluator {
459
459
  * @returns {number} 随机数
460
460
  */
461
461
  fnRAND(): number;
462
+ /**
463
+ * 取数据最后一个
464
+ *
465
+ * @example LAST(array)
466
+ * @param {...number} arr - 要处理的数组
467
+ * @namespace 数学函数
468
+ *
469
+ * @returns {any} 最后一个值
470
+ */
471
+ fnLAST(arr: Array<any>): any;
462
472
  normalizeText(raw: any): string;
463
473
  /**
464
474
  * 返回传入文本左侧的指定长度字符串。
@@ -756,6 +766,20 @@ export declare class Evaluator {
756
766
  * @returns {number} 命中的位置
757
767
  */
758
768
  fnMID(text: string, from: number, len: number): string;
769
+ /**
770
+ * 返回路径中的文件名
771
+ *
772
+ * 示例:`/home/amis/a.json`
773
+ *
774
+ * 返回:a.json`
775
+ *
776
+ * @example BASENAME(text)
777
+ * @param {string} text - 要处理的文本
778
+ * @namespace 文本函数
779
+ *
780
+ * @returns {string} 文件名
781
+ */
782
+ fnBASENAME(text: string): string | undefined;
759
783
  /**
760
784
  * 创建日期对象,可以通过特定格式的字符串,或者数值。
761
785
  *
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-formula v1.3.8
2
+ * amis-formula v1.3.9
3
3
  * Copyright 2021-2022 fex
4
4
  */
5
5
 
@@ -2515,6 +2515,18 @@ var Evaluator = /** @class */ (function () {
2515
2515
  Evaluator.prototype.fnRAND = function () {
2516
2516
  return Math.random();
2517
2517
  };
2518
+ /**
2519
+ * 取数据最后一个
2520
+ *
2521
+ * @example LAST(array)
2522
+ * @param {...number} arr - 要处理的数组
2523
+ * @namespace 数学函数
2524
+ *
2525
+ * @returns {any} 最后一个值
2526
+ */
2527
+ Evaluator.prototype.fnLAST = function (arr) {
2528
+ return arr.length ? arr[arr.length - 1] : null;
2529
+ };
2518
2530
  // 文本函数
2519
2531
  Evaluator.prototype.normalizeText = function (raw) {
2520
2532
  if (raw instanceof Date) {
@@ -2925,6 +2937,23 @@ var Evaluator = /** @class */ (function () {
2925
2937
  text = this.normalizeText(text);
2926
2938
  return text.substring(from, from + len);
2927
2939
  };
2940
+ /**
2941
+ * 返回路径中的文件名
2942
+ *
2943
+ * 示例:`/home/amis/a.json`
2944
+ *
2945
+ * 返回:a.json`
2946
+ *
2947
+ * @example BASENAME(text)
2948
+ * @param {string} text - 要处理的文本
2949
+ * @namespace 文本函数
2950
+ *
2951
+ * @returns {string} 文件名
2952
+ */
2953
+ Evaluator.prototype.fnBASENAME = function (text) {
2954
+ text = this.normalizeText(text);
2955
+ return text.split(/[\\/]/).pop();
2956
+ };
2928
2957
  // 日期函数
2929
2958
  /**
2930
2959
  * 创建日期对象,可以通过特定格式的字符串,或者数值。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amis-formula",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "负责 amis 里面的表达式实现,内置公式,编辑器等",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {