amis-formula 6.11.0 → 6.12.0-ab.1
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/esm/doc.js +1 -1
- package/esm/error.js +1 -1
- package/esm/evalutor.js +1 -1
- package/esm/evalutorForAsync.d.ts +1 -1
- package/esm/evalutorForAsync.js +72 -48
- package/esm/filter.js +1 -1
- package/esm/function.js +1 -1
- package/esm/index.js +1 -1
- package/esm/lexer.js +1 -1
- package/esm/parser.js +1 -1
- package/lib/doc.js +1 -1
- package/lib/error.js +1 -1
- package/lib/evalutor.js +1 -1
- package/lib/evalutorForAsync.d.ts +1 -1
- package/lib/evalutorForAsync.js +71 -47
- package/lib/filter.js +1 -1
- package/lib/function.js +1 -1
- package/lib/index.js +1 -1
- package/lib/lexer.js +1 -1
- package/lib/parser.js +1 -1
- package/package.json +1 -1
package/esm/doc.js
CHANGED
package/esm/error.js
CHANGED
package/esm/evalutor.js
CHANGED
|
@@ -246,7 +246,7 @@ export declare class AsyncEvaluator extends AsyncEvaluator_base {
|
|
|
246
246
|
* @example ARRAYFIND(arr, item => item === 2)
|
|
247
247
|
* @returns {any} 结果
|
|
248
248
|
*/
|
|
249
|
-
fnARRAYFIND(arr: any[], iterator: any): Promise<
|
|
249
|
+
fnARRAYFIND(arr: any[], iterator: any): Promise<any>;
|
|
250
250
|
/**
|
|
251
251
|
* 数据做数据遍历判断,需要搭配箭头函数一起使用,注意箭头函数只支持单表达式用法。
|
|
252
252
|
* 判断第二个箭头函数是否存在返回为 true 的成员。
|
package/esm/evalutorForAsync.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-formula v6.
|
|
2
|
+
* amis-formula v6.12.0-ab.1
|
|
3
3
|
* Copyright 2021-2025 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __extends, __awaiter, __generator } from 'tslib';
|
|
6
|
+
import { __extends, __awaiter, __generator, __read, __values } from 'tslib';
|
|
7
7
|
import { stripNumber, createObject, Evaluator } from './evalutor.js';
|
|
8
8
|
import { FormulaEvalError } from './error.js';
|
|
9
9
|
|
|
@@ -887,35 +887,47 @@ var AsyncEvaluator = /** @class */ (function (_super) {
|
|
|
887
887
|
*/
|
|
888
888
|
AsyncEvaluator.prototype.fnARRAYFINDINDEX = function (arr, iterator) {
|
|
889
889
|
return __awaiter(this, void 0, void 0, function () {
|
|
890
|
-
var hitIndex;
|
|
891
|
-
var
|
|
892
|
-
return __generator(this, function (
|
|
893
|
-
switch (
|
|
890
|
+
var hitIndex, items, _a, _b, _c, index, item, hit, e_1_1;
|
|
891
|
+
var e_1, _d;
|
|
892
|
+
return __generator(this, function (_e) {
|
|
893
|
+
switch (_e.label) {
|
|
894
894
|
case 0:
|
|
895
895
|
if (!iterator || iterator.type !== 'anonymous_function') {
|
|
896
896
|
throw new Error('expected an anonymous function get ' + iterator);
|
|
897
897
|
}
|
|
898
898
|
hitIndex = -1;
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
return __generator(this, function (_a) {
|
|
902
|
-
switch (_a.label) {
|
|
903
|
-
case 0: return [4 /*yield*/, promise];
|
|
904
|
-
case 1:
|
|
905
|
-
_a.sent();
|
|
906
|
-
return [4 /*yield*/, this.callAnonymousFunction(iterator, [item, index])];
|
|
907
|
-
case 2:
|
|
908
|
-
hit = _a.sent();
|
|
909
|
-
if (hit) {
|
|
910
|
-
hitIndex = index;
|
|
911
|
-
}
|
|
912
|
-
return [2 /*return*/];
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
}); }, Promise.resolve())];
|
|
899
|
+
items = Array.isArray(arr) ? arr : [];
|
|
900
|
+
_e.label = 1;
|
|
916
901
|
case 1:
|
|
917
|
-
|
|
918
|
-
|
|
902
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
903
|
+
_a = __values(items.entries()), _b = _a.next();
|
|
904
|
+
_e.label = 2;
|
|
905
|
+
case 2:
|
|
906
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
907
|
+
_c = __read(_b.value, 2), index = _c[0], item = _c[1];
|
|
908
|
+
return [4 /*yield*/, this.callAnonymousFunction(iterator, [item, index])];
|
|
909
|
+
case 3:
|
|
910
|
+
hit = _e.sent();
|
|
911
|
+
if (hit) {
|
|
912
|
+
hitIndex = index;
|
|
913
|
+
return [3 /*break*/, 5];
|
|
914
|
+
}
|
|
915
|
+
_e.label = 4;
|
|
916
|
+
case 4:
|
|
917
|
+
_b = _a.next();
|
|
918
|
+
return [3 /*break*/, 2];
|
|
919
|
+
case 5: return [3 /*break*/, 8];
|
|
920
|
+
case 6:
|
|
921
|
+
e_1_1 = _e.sent();
|
|
922
|
+
e_1 = { error: e_1_1 };
|
|
923
|
+
return [3 /*break*/, 8];
|
|
924
|
+
case 7:
|
|
925
|
+
try {
|
|
926
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
927
|
+
}
|
|
928
|
+
finally { if (e_1) throw e_1.error; }
|
|
929
|
+
return [7 /*endfinally*/];
|
|
930
|
+
case 8: return [2 /*return*/, hitIndex];
|
|
919
931
|
}
|
|
920
932
|
});
|
|
921
933
|
});
|
|
@@ -936,35 +948,47 @@ var AsyncEvaluator = /** @class */ (function (_super) {
|
|
|
936
948
|
*/
|
|
937
949
|
AsyncEvaluator.prototype.fnARRAYFIND = function (arr, iterator) {
|
|
938
950
|
return __awaiter(this, void 0, void 0, function () {
|
|
939
|
-
var hitItem;
|
|
940
|
-
var
|
|
941
|
-
return __generator(this, function (
|
|
942
|
-
switch (
|
|
951
|
+
var hitItem, items, _a, _b, _c, index, item, hit, e_2_1;
|
|
952
|
+
var e_2, _d;
|
|
953
|
+
return __generator(this, function (_e) {
|
|
954
|
+
switch (_e.label) {
|
|
943
955
|
case 0:
|
|
944
956
|
if (!iterator || iterator.type !== 'anonymous_function') {
|
|
945
957
|
throw new Error('expected an anonymous function get ' + iterator);
|
|
946
958
|
}
|
|
947
959
|
hitItem = undefined;
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
return __generator(this, function (_a) {
|
|
951
|
-
switch (_a.label) {
|
|
952
|
-
case 0: return [4 /*yield*/, promise];
|
|
953
|
-
case 1:
|
|
954
|
-
_a.sent();
|
|
955
|
-
return [4 /*yield*/, this.callAnonymousFunction(iterator, [item, index])];
|
|
956
|
-
case 2:
|
|
957
|
-
hit = _a.sent();
|
|
958
|
-
if (hit) {
|
|
959
|
-
hitItem = item;
|
|
960
|
-
}
|
|
961
|
-
return [2 /*return*/];
|
|
962
|
-
}
|
|
963
|
-
});
|
|
964
|
-
}); }, Promise.resolve())];
|
|
960
|
+
items = Array.isArray(arr) ? arr : [];
|
|
961
|
+
_e.label = 1;
|
|
965
962
|
case 1:
|
|
966
|
-
|
|
967
|
-
|
|
963
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
964
|
+
_a = __values(items.entries()), _b = _a.next();
|
|
965
|
+
_e.label = 2;
|
|
966
|
+
case 2:
|
|
967
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
968
|
+
_c = __read(_b.value, 2), index = _c[0], item = _c[1];
|
|
969
|
+
return [4 /*yield*/, this.callAnonymousFunction(iterator, [item, index])];
|
|
970
|
+
case 3:
|
|
971
|
+
hit = _e.sent();
|
|
972
|
+
if (hit) {
|
|
973
|
+
hitItem = item;
|
|
974
|
+
return [3 /*break*/, 5];
|
|
975
|
+
}
|
|
976
|
+
_e.label = 4;
|
|
977
|
+
case 4:
|
|
978
|
+
_b = _a.next();
|
|
979
|
+
return [3 /*break*/, 2];
|
|
980
|
+
case 5: return [3 /*break*/, 8];
|
|
981
|
+
case 6:
|
|
982
|
+
e_2_1 = _e.sent();
|
|
983
|
+
e_2 = { error: e_2_1 };
|
|
984
|
+
return [3 /*break*/, 8];
|
|
985
|
+
case 7:
|
|
986
|
+
try {
|
|
987
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
988
|
+
}
|
|
989
|
+
finally { if (e_2) throw e_2.error; }
|
|
990
|
+
return [7 /*endfinally*/];
|
|
991
|
+
case 8: return [2 /*return*/, hitItem];
|
|
968
992
|
}
|
|
969
993
|
});
|
|
970
994
|
});
|
package/esm/filter.js
CHANGED
package/esm/function.js
CHANGED
package/esm/index.js
CHANGED
package/esm/lexer.js
CHANGED
package/esm/parser.js
CHANGED
package/lib/doc.js
CHANGED
package/lib/error.js
CHANGED
package/lib/evalutor.js
CHANGED
|
@@ -246,7 +246,7 @@ export declare class AsyncEvaluator extends AsyncEvaluator_base {
|
|
|
246
246
|
* @example ARRAYFIND(arr, item => item === 2)
|
|
247
247
|
* @returns {any} 结果
|
|
248
248
|
*/
|
|
249
|
-
fnARRAYFIND(arr: any[], iterator: any): Promise<
|
|
249
|
+
fnARRAYFIND(arr: any[], iterator: any): Promise<any>;
|
|
250
250
|
/**
|
|
251
251
|
* 数据做数据遍历判断,需要搭配箭头函数一起使用,注意箭头函数只支持单表达式用法。
|
|
252
252
|
* 判断第二个箭头函数是否存在返回为 true 的成员。
|
package/lib/evalutorForAsync.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-formula v6.
|
|
2
|
+
* amis-formula v6.12.0-ab.1
|
|
3
3
|
* Copyright 2021-2025 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -891,35 +891,47 @@ var AsyncEvaluator = /** @class */ (function (_super) {
|
|
|
891
891
|
*/
|
|
892
892
|
AsyncEvaluator.prototype.fnARRAYFINDINDEX = function (arr, iterator) {
|
|
893
893
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
894
|
-
var hitIndex;
|
|
895
|
-
var
|
|
896
|
-
return tslib.__generator(this, function (
|
|
897
|
-
switch (
|
|
894
|
+
var hitIndex, items, _a, _b, _c, index, item, hit, e_1_1;
|
|
895
|
+
var e_1, _d;
|
|
896
|
+
return tslib.__generator(this, function (_e) {
|
|
897
|
+
switch (_e.label) {
|
|
898
898
|
case 0:
|
|
899
899
|
if (!iterator || iterator.type !== 'anonymous_function') {
|
|
900
900
|
throw new Error('expected an anonymous function get ' + iterator);
|
|
901
901
|
}
|
|
902
902
|
hitIndex = -1;
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
return tslib.__generator(this, function (_a) {
|
|
906
|
-
switch (_a.label) {
|
|
907
|
-
case 0: return [4 /*yield*/, promise];
|
|
908
|
-
case 1:
|
|
909
|
-
_a.sent();
|
|
910
|
-
return [4 /*yield*/, this.callAnonymousFunction(iterator, [item, index])];
|
|
911
|
-
case 2:
|
|
912
|
-
hit = _a.sent();
|
|
913
|
-
if (hit) {
|
|
914
|
-
hitIndex = index;
|
|
915
|
-
}
|
|
916
|
-
return [2 /*return*/];
|
|
917
|
-
}
|
|
918
|
-
});
|
|
919
|
-
}); }, Promise.resolve())];
|
|
903
|
+
items = Array.isArray(arr) ? arr : [];
|
|
904
|
+
_e.label = 1;
|
|
920
905
|
case 1:
|
|
921
|
-
|
|
922
|
-
|
|
906
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
907
|
+
_a = tslib.__values(items.entries()), _b = _a.next();
|
|
908
|
+
_e.label = 2;
|
|
909
|
+
case 2:
|
|
910
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
911
|
+
_c = tslib.__read(_b.value, 2), index = _c[0], item = _c[1];
|
|
912
|
+
return [4 /*yield*/, this.callAnonymousFunction(iterator, [item, index])];
|
|
913
|
+
case 3:
|
|
914
|
+
hit = _e.sent();
|
|
915
|
+
if (hit) {
|
|
916
|
+
hitIndex = index;
|
|
917
|
+
return [3 /*break*/, 5];
|
|
918
|
+
}
|
|
919
|
+
_e.label = 4;
|
|
920
|
+
case 4:
|
|
921
|
+
_b = _a.next();
|
|
922
|
+
return [3 /*break*/, 2];
|
|
923
|
+
case 5: return [3 /*break*/, 8];
|
|
924
|
+
case 6:
|
|
925
|
+
e_1_1 = _e.sent();
|
|
926
|
+
e_1 = { error: e_1_1 };
|
|
927
|
+
return [3 /*break*/, 8];
|
|
928
|
+
case 7:
|
|
929
|
+
try {
|
|
930
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
931
|
+
}
|
|
932
|
+
finally { if (e_1) throw e_1.error; }
|
|
933
|
+
return [7 /*endfinally*/];
|
|
934
|
+
case 8: return [2 /*return*/, hitIndex];
|
|
923
935
|
}
|
|
924
936
|
});
|
|
925
937
|
});
|
|
@@ -940,35 +952,47 @@ var AsyncEvaluator = /** @class */ (function (_super) {
|
|
|
940
952
|
*/
|
|
941
953
|
AsyncEvaluator.prototype.fnARRAYFIND = function (arr, iterator) {
|
|
942
954
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
943
|
-
var hitItem;
|
|
944
|
-
var
|
|
945
|
-
return tslib.__generator(this, function (
|
|
946
|
-
switch (
|
|
955
|
+
var hitItem, items, _a, _b, _c, index, item, hit, e_2_1;
|
|
956
|
+
var e_2, _d;
|
|
957
|
+
return tslib.__generator(this, function (_e) {
|
|
958
|
+
switch (_e.label) {
|
|
947
959
|
case 0:
|
|
948
960
|
if (!iterator || iterator.type !== 'anonymous_function') {
|
|
949
961
|
throw new Error('expected an anonymous function get ' + iterator);
|
|
950
962
|
}
|
|
951
963
|
hitItem = undefined;
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
return tslib.__generator(this, function (_a) {
|
|
955
|
-
switch (_a.label) {
|
|
956
|
-
case 0: return [4 /*yield*/, promise];
|
|
957
|
-
case 1:
|
|
958
|
-
_a.sent();
|
|
959
|
-
return [4 /*yield*/, this.callAnonymousFunction(iterator, [item, index])];
|
|
960
|
-
case 2:
|
|
961
|
-
hit = _a.sent();
|
|
962
|
-
if (hit) {
|
|
963
|
-
hitItem = item;
|
|
964
|
-
}
|
|
965
|
-
return [2 /*return*/];
|
|
966
|
-
}
|
|
967
|
-
});
|
|
968
|
-
}); }, Promise.resolve())];
|
|
964
|
+
items = Array.isArray(arr) ? arr : [];
|
|
965
|
+
_e.label = 1;
|
|
969
966
|
case 1:
|
|
970
|
-
|
|
971
|
-
|
|
967
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
968
|
+
_a = tslib.__values(items.entries()), _b = _a.next();
|
|
969
|
+
_e.label = 2;
|
|
970
|
+
case 2:
|
|
971
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
972
|
+
_c = tslib.__read(_b.value, 2), index = _c[0], item = _c[1];
|
|
973
|
+
return [4 /*yield*/, this.callAnonymousFunction(iterator, [item, index])];
|
|
974
|
+
case 3:
|
|
975
|
+
hit = _e.sent();
|
|
976
|
+
if (hit) {
|
|
977
|
+
hitItem = item;
|
|
978
|
+
return [3 /*break*/, 5];
|
|
979
|
+
}
|
|
980
|
+
_e.label = 4;
|
|
981
|
+
case 4:
|
|
982
|
+
_b = _a.next();
|
|
983
|
+
return [3 /*break*/, 2];
|
|
984
|
+
case 5: return [3 /*break*/, 8];
|
|
985
|
+
case 6:
|
|
986
|
+
e_2_1 = _e.sent();
|
|
987
|
+
e_2 = { error: e_2_1 };
|
|
988
|
+
return [3 /*break*/, 8];
|
|
989
|
+
case 7:
|
|
990
|
+
try {
|
|
991
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
992
|
+
}
|
|
993
|
+
finally { if (e_2) throw e_2.error; }
|
|
994
|
+
return [7 /*endfinally*/];
|
|
995
|
+
case 8: return [2 /*return*/, hitItem];
|
|
972
996
|
}
|
|
973
997
|
});
|
|
974
998
|
});
|
package/lib/filter.js
CHANGED
package/lib/function.js
CHANGED
package/lib/index.js
CHANGED
package/lib/lexer.js
CHANGED
package/lib/parser.js
CHANGED