amis-formula 2.0.0-beta.0 → 2.0.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amis-formula",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "负责 amis 里面的表达式实现,内置公式,编辑器等",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/evalutor.ts CHANGED
@@ -8,40 +8,7 @@ import padStart from 'lodash/padStart';
8
8
  import capitalize from 'lodash/capitalize';
9
9
  import escape from 'lodash/escape';
10
10
  import truncate from 'lodash/truncate';
11
-
12
- export interface FilterMap {
13
- [propName: string]: (this: FilterContext, input: any, ...args: any[]) => any;
14
- }
15
-
16
- export interface FunctionMap {
17
- [propName: string]: (this: Evaluator, ast: Object, data: any) => any;
18
- }
19
-
20
- export interface FilterContext {
21
- data: Object;
22
- filter?: {
23
- name: string;
24
- args: Array<any>;
25
- };
26
- restFilters: Array<{
27
- name: string;
28
- args: Array<any>;
29
- }>;
30
- }
31
-
32
- export interface EvaluatorOptions {
33
- /**
34
- * 可以外部传入 ast 节点处理器,定制或者扩充自定义函数
35
- */
36
- functions?: FunctionMap;
37
-
38
- /**
39
- * 可以外部扩充 filter
40
- */
41
- filters?: FilterMap;
42
-
43
- defaultFilter?: string;
44
- }
11
+ import {EvaluatorOptions, FilterContext, FilterMap, FunctionMap} from './types';
45
12
 
46
13
  export class Evaluator {
47
14
  readonly filters: FilterMap;
package/tsconfig.json CHANGED
@@ -1,36 +1,10 @@
1
1
  {
2
+ "extends": "../../tsconfig.json",
2
3
  "compilerOptions": {
3
- "outDir": "dist/",
4
- "module": "commonjs",
5
- "target": "es5",
6
- "lib": ["es6", "dom", "ES2015"],
7
- "sourceMap": true,
8
- "jsx": "react",
9
- "moduleResolution": "node",
10
- "rootDir": "",
11
- "importHelpers": true,
12
- "esModuleInterop": true,
13
- "allowSyntheticDefaultImports": true,
14
- "sourceRoot": "src",
15
- "noImplicitReturns": true,
16
- "noImplicitThis": true,
17
- "noImplicitAny": true,
18
- "strictNullChecks": true,
19
- "experimentalDecorators": true,
20
- "emitDecoratorMetadata": true,
21
- "skipLibCheck": true,
22
- "skipDefaultLibCheck": true,
23
- "allowJs": true
4
+ "rootDir": "./src",
5
+ "outDir": "./dist",
6
+ "typeRoots": ["./node_modules/@types"]
24
7
  },
25
8
  "include": ["src/**/*"],
26
- "exclude": [
27
- "node_modules",
28
- "build",
29
- "scripts",
30
- "acceptance-tests",
31
- "webpack",
32
- "jest",
33
- "src/setupTests.ts"
34
- ],
35
- "types": ["typePatches"]
9
+ "references": []
36
10
  }
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["./node_modules/typescript/lib/lib.es5.d.ts","./node_modules/typescript/lib/lib.es2015.d.ts","./node_modules/typescript/lib/lib.es2016.d.ts","./node_modules/typescript/lib/lib.es2017.d.ts","./node_modules/typescript/lib/lib.es2018.d.ts","./node_modules/typescript/lib/lib.es2019.d.ts","./node_modules/typescript/lib/lib.es2020.d.ts","./node_modules/typescript/lib/lib.es2021.d.ts","./node_modules/typescript/lib/lib.dom.d.ts","./node_modules/typescript/lib/lib.es2015.core.d.ts","./node_modules/typescript/lib/lib.es2015.collection.d.ts","./node_modules/typescript/lib/lib.es2015.generator.d.ts","./node_modules/typescript/lib/lib.es2015.iterable.d.ts","./node_modules/typescript/lib/lib.es2015.promise.d.ts","./node_modules/typescript/lib/lib.es2015.proxy.d.ts","./node_modules/typescript/lib/lib.es2015.reflect.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2016.array.include.d.ts","./node_modules/typescript/lib/lib.es2017.object.d.ts","./node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2017.string.d.ts","./node_modules/typescript/lib/lib.es2017.intl.d.ts","./node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","./node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","./node_modules/typescript/lib/lib.es2018.intl.d.ts","./node_modules/typescript/lib/lib.es2018.promise.d.ts","./node_modules/typescript/lib/lib.es2018.regexp.d.ts","./node_modules/typescript/lib/lib.es2019.array.d.ts","./node_modules/typescript/lib/lib.es2019.object.d.ts","./node_modules/typescript/lib/lib.es2019.string.d.ts","./node_modules/typescript/lib/lib.es2019.symbol.d.ts","./node_modules/typescript/lib/lib.es2020.bigint.d.ts","./node_modules/typescript/lib/lib.es2020.promise.d.ts","./node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2020.string.d.ts","./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2020.intl.d.ts","./node_modules/typescript/lib/lib.es2021.promise.d.ts","./node_modules/typescript/lib/lib.es2021.string.d.ts","./node_modules/typescript/lib/lib.es2021.weakref.d.ts","./node_modules/typescript/lib/lib.es2021.intl.d.ts","./node_modules/typescript/lib/lib.esnext.intl.d.ts","./node_modules/tslib/tslib.d.ts","./node_modules/moment/ts3.1-typings/moment.d.ts","./node_modules/@types/lodash/common/common.d.ts","./node_modules/@types/lodash/common/array.d.ts","./node_modules/@types/lodash/common/collection.d.ts","./node_modules/@types/lodash/common/date.d.ts","./node_modules/@types/lodash/common/function.d.ts","./node_modules/@types/lodash/common/lang.d.ts","./node_modules/@types/lodash/common/math.d.ts","./node_modules/@types/lodash/common/number.d.ts","./node_modules/@types/lodash/common/object.d.ts","./node_modules/@types/lodash/common/seq.d.ts","./node_modules/@types/lodash/common/string.d.ts","./node_modules/@types/lodash/common/util.d.ts","./node_modules/@types/lodash/index.d.ts","./node_modules/@types/lodash/upperfirst.d.ts","./node_modules/@types/lodash/padstart.d.ts","./node_modules/@types/lodash/capitalize.d.ts","./node_modules/@types/lodash/escape.d.ts","./node_modules/@types/lodash/truncate.d.ts","./src/types.ts","./src/evalutor.ts","./src/filter.ts","./src/lexer.ts","./src/parser.ts","./src/index.ts","./node_modules/@babel/types/lib/index.d.ts","./node_modules/@types/babel__generator/index.d.ts","./node_modules/@babel/parser/typings/babel-parser.d.ts","./node_modules/@types/babel__template/index.d.ts","./node_modules/@types/babel__traverse/index.d.ts","./node_modules/@types/babel__core/index.d.ts","./node_modules/@types/doctrine/index.d.ts","./node_modules/@types/eslint/helpers.d.ts","./node_modules/@types/json-schema/index.d.ts","./node_modules/@types/estree/index.d.ts","./node_modules/@types/eslint/index.d.ts","./node_modules/@types/eslint-scope/index.d.ts","./node_modules/@types/node/assert.d.ts","./node_modules/@types/node/assert/strict.d.ts","./node_modules/@types/node/globals.d.ts","./node_modules/@types/node/async_hooks.d.ts","./node_modules/@types/node/buffer.d.ts","./node_modules/@types/node/child_process.d.ts","./node_modules/@types/node/cluster.d.ts","./node_modules/@types/node/console.d.ts","./node_modules/@types/node/constants.d.ts","./node_modules/@types/node/crypto.d.ts","./node_modules/@types/node/dgram.d.ts","./node_modules/@types/node/diagnostics_channel.d.ts","./node_modules/@types/node/dns.d.ts","./node_modules/@types/node/dns/promises.d.ts","./node_modules/@types/node/domain.d.ts","./node_modules/@types/node/events.d.ts","./node_modules/@types/node/fs.d.ts","./node_modules/@types/node/fs/promises.d.ts","./node_modules/@types/node/http.d.ts","./node_modules/@types/node/http2.d.ts","./node_modules/@types/node/https.d.ts","./node_modules/@types/node/inspector.d.ts","./node_modules/@types/node/module.d.ts","./node_modules/@types/node/net.d.ts","./node_modules/@types/node/os.d.ts","./node_modules/@types/node/path.d.ts","./node_modules/@types/node/perf_hooks.d.ts","./node_modules/@types/node/process.d.ts","./node_modules/@types/node/punycode.d.ts","./node_modules/@types/node/querystring.d.ts","./node_modules/@types/node/readline.d.ts","./node_modules/@types/node/repl.d.ts","./node_modules/@types/node/stream.d.ts","./node_modules/@types/node/stream/promises.d.ts","./node_modules/@types/node/stream/consumers.d.ts","./node_modules/@types/node/stream/web.d.ts","./node_modules/@types/node/string_decoder.d.ts","./node_modules/@types/node/timers.d.ts","./node_modules/@types/node/timers/promises.d.ts","./node_modules/@types/node/tls.d.ts","./node_modules/@types/node/trace_events.d.ts","./node_modules/@types/node/tty.d.ts","./node_modules/@types/node/url.d.ts","./node_modules/@types/node/util.d.ts","./node_modules/@types/node/v8.d.ts","./node_modules/@types/node/vm.d.ts","./node_modules/@types/node/wasi.d.ts","./node_modules/@types/node/worker_threads.d.ts","./node_modules/@types/node/zlib.d.ts","./node_modules/@types/node/globals.global.d.ts","./node_modules/@types/node/index.d.ts","./node_modules/@types/graceful-fs/index.d.ts","./node_modules/@types/istanbul-lib-coverage/index.d.ts","./node_modules/@types/istanbul-lib-report/index.d.ts","./node_modules/@types/istanbul-reports/index.d.ts","./node_modules/jest-diff/build/cleanupsemantic.d.ts","./node_modules/pretty-format/build/types.d.ts","./node_modules/pretty-format/build/index.d.ts","./node_modules/jest-diff/build/types.d.ts","./node_modules/jest-diff/build/difflines.d.ts","./node_modules/jest-diff/build/printdiffs.d.ts","./node_modules/jest-diff/build/index.d.ts","./node_modules/@types/jest/index.d.ts","./node_modules/@types/unist/index.d.ts","./node_modules/@types/mdast/index.d.ts","./node_modules/@types/minimist/index.d.ts","./node_modules/@types/normalize-package-data/index.d.ts","./node_modules/@types/parse-json/index.d.ts","./node_modules/@types/prettier/index.d.ts","./node_modules/@types/resolve/index.d.ts","./node_modules/@types/stack-utils/index.d.ts","./node_modules/@types/yargs-parser/index.d.ts","./node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"89f78430e422a0f06d13019d60d5a45b37ec2d28e67eb647f73b1b0d19a46b72","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f",{"version":"abba1071bfd89e55e88a054b0c851ea3e8a494c340d0f3fab19eb18f6afb0c9e","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"4378fc8122ec9d1a685b01eb66c46f62aba6b239ca7228bb6483bcf8259ee493","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"d071129cba6a5f2700be09c86c07ad2791ab67d4e5ed1eb301d6746c62745ea4","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"e8c9f4e445a489991ca1a4232667de3ac36b07ba75ea335971fbeacf2d26fe67","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"12f4cfe2fe60b810c3174537bc2ddb20c1067b7768643d12cb1266fd183afb75","f97edc4d3b4dd0b32766e9633086497565c37657fb591cc84a35864db4bc2fc5","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","fe4a2042d087990ebfc7dc0142d5aaf5a152e4baea86b45f283f103ec1e871ea","d88a479cccf787b4aa82362150fbeba5211a32dbfafa7b92ba6995ecaf9a1a89","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","ae9930989ed57478eb03b9b80ad3efa7a3eacdfeff0f78ecf7894c4963a64f93","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","6ac6f24aff52e62c3950461aa17eab26e3a156927858e6b654baef0058b4cd1e",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"bf2e94b15a1192080e4c41ed49b31d19a08320aee17f08c0d531bb1f0f5914b5","0aff5c7f500f7b0947b194e181536238d455d73849b32f635783b2b319bf5317","901f60f74395a0a217bfcbe3195f793ad5e0f586b73792fa968a20162c4cb17b","5f562cbdc445ecb2843deeaa4f90de598a090d1d5c42753944dc084a237b63bd","166c1b5eb2abf5af8b31a6862dc9d2d9378ab4f685a8bf5f8720321c7af47e31",{"version":"6f5044561fe287962c00566d784b9f8f029680c87930e40b2bfd63481ad383f3","signature":"5ecda39d7b008f9090d519d0bd4a8bb3bbc93819220def3a7405271c96582c34"},{"version":"5b1b8b1a2c0e509eb190ac8d8606932c51f7d1a9553f53b5758d2fdab66cf4e6","signature":"2cdf62ac0953cd2cc1a60b85cd5fca25d847df5c70e38277821a4cd81a9aeb89"},{"version":"85b58cad263e24cba2c5b291b96a18a9aaeca8d89a7c4fceaadf6a2e6f30e2fd","signature":"95ddcdc8f765bc416c84edaebaee00770b73b0f6cf0e84eaf31f47e234623dbd"},{"version":"2298176adba08f0715d9d6cc6b4e661596c2e36a9d684df6d5216e4513ad6609","signature":"2313da42c842a92d8cfb7c047179a80b035e1e528e39fd6f7b9f6bb937356449"},{"version":"16e9069c7b6d7b0fdc7c595c298657935d6f0a64b5317510b3840509e38058e3","signature":"0bcf6c2f97f104cf1223157dde7f422fa275da59185e28be91f042219fada045"},{"version":"3b0ff9deb919ee171079be451d93dc4ec7c8a44e1d2dad1bd50ff2713e525973","signature":"4a6986540d038622d0f8575e25c0da783c0320d0bcc7d273440f325309fe04cb"},"272c2dac4baaf7fdd2d7efeef0fa2547af54cc21883c5e138b8c4d1661697a54","8dfed5c91ad36e69e6da6b7e49be929d4e19666db2b651aa839c485170a2902c","64b867c61effed7b5bc0cc06b3d8eac23b067a3fba581fc7d3c292fa593e6a45","93de1c6dab503f053efe8d304cb522bb3a89feab8c98f307a674a4fae04773e9","3b043cf9a81854a72963fdb57d1884fc4da1cf5be69b5e0a4c5b751e58cb6d88","80164ffebe1723a50e020a648e0623c026ff39be13c5cd45e6a82d0fcc06e2d0","f080c653683941a5c743151f8afd43eb07e514205e968f46cb97ed0d3bb28623",{"version":"64d4b35c5456adf258d2cf56c341e203a073253f229ef3208fc0d5020253b241","affectsGlobalScope":true},"0359682c54e487c4cab2b53b2b4d35cc8dea4d9914bc6abcdb5701f8b8e745a4","7d7c8ef7d48a035142c07dae60545ecc0e4af4c337742760cb09726f2f8e31db","a93f2966a163982b102e5bfec0a1d0a5317f6e56ab8d59051236fffd9f675b99","82772e5d55062a042a2715a555d347275a663940926fc785705eb082010cb9f6","0d5a2ee1fdfa82740e0103389b9efd6bfe145a20018a2da3c02b89666181f4d9","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"92d63add669d18ebc349efbacd88966d6f2ccdddfb1b880b2db98ae3aa7bf7c4","affectsGlobalScope":true},"ccc94049a9841fe47abe5baef6be9a38fc6228807974ae675fb15dc22531b4be",{"version":"9acfe4d1ff027015151ce81d60797b04b52bffe97ad8310bb0ec2e8fd61e1303","affectsGlobalScope":true},"95843d5cfafced8f3f8a5ce57d2335f0bcd361b9483587d12a25e4bd403b8216","afc6e96061af46bcff47246158caee7e056f5288783f2d83d6858cd25be1c565",{"version":"34f5bcac12b36d70304b73de5f5aab3bb91bd9919f984be80579ebcad03a624e","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","2f520601649a893e6a49a8851ebfcf4be8ce090dc1281c2a08a871cb04e8251f","f50c975ab7b50e25a69e3d8a3773894125b44e9698924105f23b812bf7488baf","2b8c764f856a1dd0a9a2bf23e5efddbff157de8138b0754010be561ae5fcaa90","76650408392bf49a8fbf3e2b6b302712a92d76af77b06e2da1cc8077359c4409","0af3121e68297b2247dd331c0d24dba599e50736a7517a5622d5591aae4a3122","6972fca26f6e9bd56197568d4379f99071a90766e06b4fcb5920a0130a9202be",{"version":"4a2628e95962c8ab756121faa3ac2ed348112ff7a87b5c286dd2cc3326546b4c","affectsGlobalScope":true},"80793b2277f31baa199234daed806fff0fb11491d1ebd3357e520c3558063f00","a049a59a02009fc023684fcfaf0ac526fe36c35dcc5d2b7d620c1750ba11b083","b9b963043551b034abd9e7c6d859f7a81d99479fde938d983114d167d0644a78","b287b810b5035d5685f1df6e1e418f1ca452a3ed4f59fd5cc081dbf2045f0d9b","4b9a003b5c556c96784132945bb41c655ea11273b1917f5c8d0c154dd5fd20dd","a458dc78104cc80048ac24fdc02fe6dce254838094c2f25641b3f954d9721241",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"902cd98bf46e95caf4118a0733fb801e9e90eec3edaed6abdad77124afec9ca2","abc1c425b2ad6720433f40f1877abfa4223f0f3dd486c9c28c492179ca183cb6","cd4854d38f4eb5592afd98ab95ca17389a7dfe38013d9079e802d739bdbcc939","94eed4cc2f5f658d5e229ff1ccd38860bddf4233e347bf78edd2154dee1f2b99",{"version":"bd1a08e30569b0fb2f0b21035eb9b039871f68faa9b98accf847e9c878c5e0a9","affectsGlobalScope":true},"9f1069b9e2c051737b1f9b4f1baf50e4a63385a6a89c32235549ae87fc3d5492","ee18f2da7a037c6ceeb112a084e485aead9ea166980bf433474559eac1b46553","29c2706fa0cc49a2bd90c83234da33d08bb9554ecec675e91c1f85087f5a5324","0acbf26bf958f9e80c1ffa587b74749d2697b75b484062d36e103c137c562bc3","d7838022c7dab596357a9604b9c6adffe37dc34085ce0779c958ce9545bd7139","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"a7971f9fb2a32ec7788ec6cda9d7a33c02023dfe9a62db2030ad1359649d8050","c33a6ea7147af60d8e98f1ac127047f4b0d4e2ce28b8f08ff3de07ca7cc00637",{"version":"b42b47e17b8ece2424ae8039feb944c2e3ba4b262986aebd582e51efbdca93dc","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","2408611d9b4146e35d1dbd1f443ccd8e187c74614a54b80300728277529dbf11","998a3de5237518c0b3ac00a11b3b4417affb008aa20aedee52f3fdae3cb86151","ad41008ffe077206e1811fc873f4d9005b5fd7f6ab52bb6118fef600815a5cb4","d88ecca73348e7c337541c4b8b60a50aca5e87384f6b8a422fc6603c637e4c21","badae0df9a8016ac36994b0a0e7b82ba6aaa3528e175a8c3cb161e4683eec03e","c3db860bcaaaeb3bbc23f353bbda1f8ab82756c8d5e973bebb3953cb09ea68f2","235a53595bd20b0b0eeb1a29cb2887c67c48375e92f03749b2488fbd46d0b1a0","bc09393cd4cd13f69cf1366d4236fbae5359bb550f0de4e15767e9a91d63dfb1","9c266243b01545e11d2733a55ad02b4c00ecdbda99c561cd1674f96e89cdc958","c71155c05fc76ff948a4759abc1cb9feec036509f500174bc18dad4c7827a60c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"1cdb8f094b969dcc183745dc88404e2d8fcf2a858c6e7cc2441011476573238e","3ebae8c00411116a66fca65b08228ea0cf0b72724701f9b854442100aab55aba","de18acda71730bac52f4b256ce7511bb56cc21f6f114c59c46782eff2f632857","7eb06594824ada538b1d8b48c3925a83e7db792f47a081a62cf3e5c4e23cf0ee","f5638f7c2f12a9a1a57b5c41b3c1ea7db3876c003bab68e6a57afd6bcc169af0","d8aab31ba8e618cc3eea10b0945de81cb93b7e8150a013a482332263b9305322","462bccdf75fcafc1ae8c30400c9425e1a4681db5d605d1a0edb4f990a54d8094","5923d8facbac6ecf7c84739a5c701a57af94a6f6648d6229a6c768cf28f0f8cb","7adecb2c3238794c378d336a8182d4c3dd2c4fa6fa1785e2797a3db550edea62","dc12dc0e5aa06f4e1a7692149b78f89116af823b9e1f1e4eae140cd3e0e674e6","1bfc6565b90c8771615cd8cfcf9b36efc0275e5e83ac7d9181307e96eb495161","8a8a96898906f065f296665e411f51010b51372fa260d5373bf9f64356703190",{"version":"e9f2cdc4e98e73a606ff68c470a8cb4f23cd638c47649d71b90a2d9413102080","affectsGlobalScope":true},"cddf5c26907c0b8378bc05543161c11637b830da9fadf59e02a11e675d11e180","2a2e2c6463bcf3c59f31bc9ab4b6ef963bbf7dffb049cd017e2c1834e3adca63","209e814e8e71aec74f69686a9506dd7610b97ab59dcee9446266446f72a76d05","6fa0008bf91a4cc9c8963bace4bba0bd6865cbfa29c3e3ccc461155660fb113a","2b8264b2fefd7367e0f20e2c04eed5d3038831fe00f5efbc110ff0131aab899b","9d9e658d1d5b805562749ce383ef8c67ccb796394d8734d9c138788d7dab6ee3","2880728492d6a6baa55411d14cc42fa55714a24b1d1d27ff9a8a610abd47c761","b0d10e46cfe3f6c476b69af02eaa38e4ccc7430221ce3109ae84bb9fb8282298","f7e133b20ee2669b6c0e5d7f0cd510868c57cd64b283e68c7f598e30ce9d76d2","6ba73232c9d3267ca36ddb83e335d474d2c0e167481e3dec416c782894e11438"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./dist","declarationMap":true,"emitDeclarationOnly":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"importHelpers":true,"jsx":2,"module":1,"noImplicitAny":true,"noImplicitReturns":true,"noImplicitThis":true,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"sourceRoot":"","strictNullChecks":true,"target":1},"fileIdsList":[[71,126],[126],[71,72,73,74,75,126],[71,73,126],[80,81,126],[78,79,80,126],[99,126,133],[126,135],[126,136],[126,140,144],[59,126],[47,49,50,51,52,53,54,55,56,57,58,59,126],[47,48,50,51,52,53,54,55,56,57,58,59,126],[48,49,50,51,52,53,54,55,56,57,58,59,126],[47,48,49,51,52,53,54,55,56,57,58,59,126],[47,48,49,50,52,53,54,55,56,57,58,59,126],[47,48,49,50,51,53,54,55,56,57,58,59,126],[47,48,49,50,51,52,54,55,56,57,58,59,126],[47,48,49,50,51,52,53,55,56,57,58,59,126],[47,48,49,50,51,52,53,54,56,57,58,59,126],[47,48,49,50,51,52,53,54,55,57,58,59,126],[47,48,49,50,51,52,53,54,55,56,58,59,126],[47,48,49,50,51,52,53,54,55,56,57,59,126],[47,48,49,50,51,52,53,54,55,56,57,58,126],[126,146],[83,126],[86,126],[87,92,126],[88,98,99,106,115,125,126],[88,89,98,106,126],[90,126],[91,92,99,107,126],[92,115,122,126],[93,95,98,106,126],[94,126],[95,96,126],[97,98,126],[98,126],[98,99,100,115,125,126],[98,99,100,115,126],[101,106,115,125,126],[98,99,101,102,106,115,122,125,126],[101,103,115,122,125,126],[83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132],[98,104,126],[105,125,126],[95,98,106,115,126],[107,126],[108,126],[86,109,126],[110,124,126,130],[111,126],[112,126],[98,113,126],[113,114,126,128],[98,115,116,117,126],[115,117,126],[115,116,126],[118,126],[119,126],[98,120,121,126],[120,121,126],[92,106,122,126],[123,126],[106,124,126],[87,101,112,125,126],[92,126],[115,126,127],[126,128],[126,129],[87,92,98,100,109,115,125,126,128,130],[115,126,131],[126,133],[126,154],[126,138,141],[126,138,141,142,143],[126,140],[126,139],[45,46,60,61,62,63,64,65,126],[45,65,66,126],[45,65,66,67,68,69,126],[45,65,126],[45,65,68,126],[45,66,126],[66,67],[65],[66]],"referencedMap":[[73,1],[71,2],[76,3],[72,1],[74,4],[75,1],[77,2],[82,5],[78,2],[81,6],[80,2],[134,7],[135,2],[136,8],[137,9],[145,10],[79,2],[62,11],[48,12],[49,13],[47,14],[50,15],[51,16],[52,17],[53,18],[54,19],[55,20],[56,21],[57,22],[58,23],[63,11],[59,24],[61,11],[64,11],[60,11],[147,25],[148,2],[83,26],[84,26],[86,27],[87,28],[88,29],[89,30],[90,31],[91,32],[92,33],[93,34],[94,35],[95,36],[96,36],[97,37],[98,38],[99,39],[100,40],[85,2],[132,2],[101,41],[102,42],[103,43],[133,44],[104,45],[105,46],[106,47],[107,48],[108,49],[109,50],[110,51],[111,52],[112,53],[113,54],[114,55],[115,56],[117,57],[116,58],[118,59],[119,60],[120,61],[121,62],[122,63],[123,64],[124,65],[125,66],[126,67],[127,68],[128,69],[129,70],[130,71],[131,72],[149,2],[150,2],[151,2],[152,73],[153,2],[146,2],[154,2],[155,74],[138,2],[142,75],[144,76],[143,75],[141,77],[46,2],[140,78],[139,2],[45,2],[9,2],[11,2],[10,2],[2,2],[12,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[3,2],[4,2],[23,2],[20,2],[21,2],[22,2],[24,2],[25,2],[26,2],[5,2],[27,2],[28,2],[29,2],[30,2],[6,2],[31,2],[32,2],[33,2],[34,2],[7,2],[39,2],[35,2],[36,2],[37,2],[38,2],[8,2],[43,2],[40,2],[41,2],[42,2],[1,2],[44,2],[66,79],[67,80],[70,81],[68,82],[69,83],[65,84]],"exportedModulesMap":[[73,1],[71,2],[76,3],[72,1],[74,4],[75,1],[77,2],[82,5],[78,2],[81,6],[80,2],[134,7],[135,2],[136,8],[137,9],[145,10],[79,2],[62,11],[48,12],[49,13],[47,14],[50,15],[51,16],[52,17],[53,18],[54,19],[55,20],[56,21],[57,22],[58,23],[63,11],[59,24],[61,11],[64,11],[60,11],[147,25],[148,2],[83,26],[84,26],[86,27],[87,28],[88,29],[89,30],[90,31],[91,32],[92,33],[93,34],[94,35],[95,36],[96,36],[97,37],[98,38],[99,39],[100,40],[85,2],[132,2],[101,41],[102,42],[103,43],[133,44],[104,45],[105,46],[106,47],[107,48],[108,49],[109,50],[110,51],[111,52],[112,53],[113,54],[114,55],[115,56],[117,57],[116,58],[118,59],[119,60],[120,61],[121,62],[122,63],[123,64],[124,65],[125,66],[126,67],[127,68],[128,69],[129,70],[130,71],[131,72],[149,2],[150,2],[151,2],[152,73],[153,2],[146,2],[154,2],[155,74],[138,2],[142,75],[144,76],[143,75],[141,77],[46,2],[140,78],[139,2],[45,2],[9,2],[11,2],[10,2],[2,2],[12,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[3,2],[4,2],[23,2],[20,2],[21,2],[22,2],[24,2],[25,2],[26,2],[5,2],[27,2],[28,2],[29,2],[30,2],[6,2],[31,2],[32,2],[33,2],[34,2],[7,2],[39,2],[35,2],[36,2],[37,2],[38,2],[8,2],[43,2],[40,2],[41,2],[42,2],[1,2],[44,2],[70,85],[68,86],[69,86],[65,87]],"semanticDiagnosticsPerFile":[73,71,76,72,74,75,77,82,78,81,80,134,135,136,137,145,79,62,48,49,47,50,51,52,53,54,55,56,57,58,63,59,61,64,60,147,148,83,84,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,85,132,101,102,103,133,104,105,106,107,108,109,110,111,112,113,114,115,117,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,149,150,151,152,153,146,154,155,138,142,144,143,141,46,140,139,45,9,11,10,2,12,13,14,15,16,17,18,19,3,4,23,20,21,22,24,25,26,5,27,28,29,30,6,31,32,33,34,7,39,35,36,37,38,8,43,40,41,42,1,44,66,67,70,68,69,65]},"version":"4.5.4"}
@@ -1,1070 +0,0 @@
1
- /**
2
- * @file 公式内置函数
3
- */
4
- export interface FilterMap {
5
- [propName: string]: (this: FilterContext, input: any, ...args: any[]) => any;
6
- }
7
- export interface FunctionMap {
8
- [propName: string]: (this: Evaluator, ast: Object, data: any) => any;
9
- }
10
- export interface FilterContext {
11
- data: Object;
12
- filter?: {
13
- name: string;
14
- args: Array<any>;
15
- };
16
- restFilters: Array<{
17
- name: string;
18
- args: Array<any>;
19
- }>;
20
- }
21
- export interface EvaluatorOptions {
22
- /**
23
- * 可以外部传入 ast 节点处理器,定制或者扩充自定义函数
24
- */
25
- functions?: FunctionMap;
26
- /**
27
- * 可以外部扩充 filter
28
- */
29
- filters?: FilterMap;
30
- defaultFilter?: string;
31
- }
32
- export declare class Evaluator {
33
- readonly options: EvaluatorOptions;
34
- readonly filters: FilterMap;
35
- readonly functions: FunctionMap;
36
- readonly context: {
37
- [propName: string]: any;
38
- };
39
- contextStack: Array<(varname: string) => any>;
40
- static defaultFilters: FilterMap;
41
- static setDefaultFilters(filters: FilterMap): void;
42
- constructor(context: {
43
- [propName: string]: any;
44
- }, options?: EvaluatorOptions);
45
- evalute(ast: any): any;
46
- document(ast: {
47
- type: 'document';
48
- body: Array<any>;
49
- }): any;
50
- filter(ast: {
51
- type: 'filter';
52
- input: any;
53
- filters: Array<{
54
- name: string;
55
- args: Array<any>;
56
- }>;
57
- }): any;
58
- raw(ast: {
59
- type: 'raw';
60
- value: string;
61
- }): string;
62
- script(ast: {
63
- type: 'script';
64
- body: any;
65
- }): any;
66
- expressionList(ast: {
67
- type: 'expression-list';
68
- body: Array<any>;
69
- }): any;
70
- template(ast: {
71
- type: 'template';
72
- body: Array<any>;
73
- }): string;
74
- templateRaw(ast: {
75
- type: 'template_raw';
76
- value: any;
77
- }): any;
78
- getter(ast: {
79
- host: any;
80
- key: any;
81
- }): any;
82
- unary(ast: {
83
- op: '+' | '-' | '~' | '!';
84
- value: any;
85
- }): number | boolean;
86
- formatNumber(value: any, int?: boolean): any;
87
- power(ast: {
88
- left: any;
89
- right: any;
90
- }): number;
91
- multiply(ast: {
92
- left: any;
93
- right: any;
94
- }): number;
95
- divide(ast: {
96
- left: any;
97
- right: any;
98
- }): number;
99
- remainder(ast: {
100
- left: any;
101
- right: any;
102
- }): number;
103
- add(ast: {
104
- left: any;
105
- right: any;
106
- }): number;
107
- minus(ast: {
108
- left: any;
109
- right: any;
110
- }): number;
111
- shift(ast: {
112
- op: '<<' | '>>' | '>>>';
113
- left: any;
114
- right: any;
115
- }): number;
116
- lt(ast: {
117
- left: any;
118
- right: any;
119
- }): boolean;
120
- gt(ast: {
121
- left: any;
122
- right: any;
123
- }): boolean;
124
- le(ast: {
125
- left: any;
126
- right: any;
127
- }): boolean;
128
- ge(ast: {
129
- left: any;
130
- right: any;
131
- }): boolean;
132
- eq(ast: {
133
- left: any;
134
- right: any;
135
- }): boolean;
136
- ne(ast: {
137
- left: any;
138
- right: any;
139
- }): boolean;
140
- streq(ast: {
141
- left: any;
142
- right: any;
143
- }): boolean;
144
- strneq(ast: {
145
- left: any;
146
- right: any;
147
- }): boolean;
148
- binary(ast: {
149
- op: '&' | '^' | '|';
150
- left: any;
151
- right: any;
152
- }): number;
153
- and(ast: {
154
- left: any;
155
- right: any;
156
- }): any;
157
- or(ast: {
158
- left: any;
159
- right: any;
160
- }): any;
161
- number(ast: {
162
- value: any;
163
- raw: string;
164
- }): any;
165
- nsVariable(ast: {
166
- namespace: string;
167
- body: any;
168
- }): any;
169
- variable(ast: {
170
- name: string;
171
- }): any;
172
- identifier(ast: {
173
- name: string;
174
- }): string;
175
- array(ast: {
176
- type: 'array';
177
- members: Array<any>;
178
- }): any[];
179
- literal(ast: {
180
- type: 'literal';
181
- value: any;
182
- }): any;
183
- string(ast: {
184
- type: 'string';
185
- value: string;
186
- }): string;
187
- object(ast: {
188
- members: Array<{
189
- key: string;
190
- value: any;
191
- }>;
192
- }): any;
193
- conditional(ast: {
194
- type: 'conditional';
195
- test: any;
196
- consequent: any;
197
- alternate: any;
198
- }): any;
199
- funcCall(this: any, ast: {
200
- identifier: string;
201
- args: Array<any>;
202
- }): any;
203
- anonymousFunction(ast: any): any;
204
- callAnonymousFunction(ast: {
205
- args: any[];
206
- return: any;
207
- }, args: Array<any>): any;
208
- /**
209
- * 示例:IF(A, B, C)
210
- *
211
- * 如果满足条件A,则返回B,否则返回C,支持多层嵌套IF函数。
212
- *
213
- * 也可以用表达式如:A ? B : C
214
- *
215
- * @example IF(condition, consequent, alternate)
216
- * @param {expression} condition - 条件表达式.
217
- * @param {any} consequent 条件判断通过的返回结果
218
- * @param {any} alternate 条件判断不通过的返回结果
219
- * @namespace 逻辑函数
220
- *
221
- * @returns {any} 根据条件返回不同的结果
222
- */
223
- fnIF(condition: () => any, trueValue: () => any, falseValue: () => any): any;
224
- /**
225
- * 条件全部符合,返回 true,否则返回 false
226
- *
227
- * 示例:AND(语文成绩>80, 数学成绩>80)
228
- *
229
- * 语文成绩和数学成绩都大于 80,则返回 true,否则返回 false
230
- *
231
- * 也可以直接用表达式如:语文成绩>80 && 数学成绩>80
232
- *
233
- * @example AND(expression1, expression2, ...expressionN)
234
- * @param {...expression} conditions - 条件表达式.
235
- * @namespace 逻辑函数
236
- *
237
- * @returns {boolean}
238
- */
239
- fnAND(...condtions: Array<() => any>): boolean;
240
- /**
241
- * 条件任意一个满足条件,返回 true,否则返回 false
242
- *
243
- * 示例:OR(语文成绩>80, 数学成绩>80)
244
- *
245
- * 语文成绩和数学成绩任意一个大于 80,则返回 true,否则返回 false
246
- *
247
- * 也可以直接用表达式如:语文成绩>80 || 数学成绩>80
248
- *
249
- * @example OR(expression1, expression2, ...expressionN)
250
- * @param {...expression} conditions - 条件表达式.
251
- * @namespace 逻辑函数
252
- *
253
- * @returns {boolean}
254
- */
255
- fnOR(...condtions: Array<() => any>): boolean;
256
- /**
257
- * 异或处理,两个表达式同时为「真」,或者同时为「假」,则结果返回为「真」
258
- *
259
- * @example XOR(condition1, condition2)
260
- * @param {expression} condition1 - 条件表达式1
261
- * @param {expression} condition2 - 条件表达式2
262
- * @namespace 逻辑函数
263
- *
264
- * @returns {boolean}
265
- */
266
- fnXOR(c1: () => any, c2: () => any): boolean;
267
- /**
268
- * 判断函数集合,相当于多个 else if 合并成一个。
269
- *
270
- * 示例:IFS(语文成绩 > 80, "优秀", 语文成绩 > 60, "良", "继续努力")
271
- *
272
- * 如果语文成绩大于 80,则返回优秀,否则判断大于 60 分,则返回良,否则返回继续努力。
273
- *
274
- * @example IFS(condition1, result1, condition2, result2,...conditionN, resultN)
275
- * @param {...any} args - 条件,返回值集合
276
- * @namespace 逻辑函数
277
- * @returns {any} 第一个满足条件的结果,没有命中的返回 false。
278
- */
279
- fnIFS(...args: Array<() => any>): any;
280
- /**
281
- * 返回传入数字的绝对值
282
- *
283
- * @example ABS(num)
284
- * @param {number} num - 数值
285
- * @namespace 数学函数
286
- *
287
- * @returns {number} 传入数值的绝对值
288
- */
289
- fnABS(a: number): number;
290
- /**
291
- * 获取最大值,如果只有一个参数且是数组,则计算这个数组内的值
292
- *
293
- * @example MAX(num1, num2, ...numN)
294
- * @param {...number} num - 数值
295
- * @namespace 数学函数
296
- *
297
- * @returns {number} 所有传入值中最大的那个
298
- */
299
- fnMAX(...args: Array<any>): any;
300
- /**
301
- * 获取最小值,如果只有一个参数且是数组,则计算这个数组内的值
302
- *
303
- * @example MIN(num1, num2, ...numN)
304
- * @param {...number} num - 数值
305
- * @namespace 数学函数
306
- *
307
- * @returns {number} 所有传入值中最小的那个
308
- */
309
- fnMIN(...args: Array<number>): any;
310
- /**
311
- * 求和,如果只有一个参数且是数组,则计算这个数组内的值
312
- *
313
- * @example SUM(num1, num2, ...numN)
314
- * @param {...number} num - 数值
315
- * @namespace 数学函数
316
- *
317
- * @returns {number} 所有传入数值的总和
318
- */
319
- fnSUM(...args: Array<number>): any;
320
- /**
321
- * 将数值向下取整为最接近的整数
322
- *
323
- * @example INT(num)
324
- * @param {number} num - 数值
325
- * @namespace 数学函数
326
- *
327
- * @returns {number} 数值对应的整形
328
- */
329
- fnINT(n: number): number;
330
- /**
331
- * 返回两数相除的余数,参数 number 是被除数,divisor 是除数
332
- *
333
- * @example MOD(num, divisor)
334
- * @param {number} num - 被除数
335
- * @param {number} divisor - 除数
336
- * @namespace 数学函数
337
- *
338
- * @returns {number} 两数相除的余数
339
- */
340
- fnMOD(a: number, b: number): number;
341
- /**
342
- * 圆周率 3.1415...
343
- *
344
- * @example PI()
345
- * @namespace 数学函数
346
- *
347
- * @returns {number} 圆周率数值
348
- */
349
- fnPI(): number;
350
- /**
351
- * 将数字四舍五入到指定的位数,可以设置小数位。
352
- *
353
- * @example ROUND(num[, numDigits = 2])
354
- * @param {number} num - 要处理的数字
355
- * @param {number} numDigits - 小数位数
356
- * @namespace 数学函数
357
- *
358
- * @returns {number} 传入数值四舍五入后的结果
359
- */
360
- fnROUND(a: number, b: number): number;
361
- /**
362
- * 将数字向下取整到指定的位数,可以设置小数位。
363
- *
364
- * @example FLOOR(num[, numDigits=2])
365
- * @param {number} num - 要处理的数字
366
- * @param {number} numDigits - 小数位数
367
- * @namespace 数学函数
368
- *
369
- * @returns {number} 传入数值向下取整后的结果
370
- */
371
- fnFLOOR(a: number, b: number): number;
372
- /**
373
- * 将数字向上取整到指定的位数,可以设置小数位。
374
- *
375
- * @example CEIL(num[, numDigits=2])
376
- * @param {number} num - 要处理的数字
377
- * @param {number} numDigits - 小数位数
378
- * @namespace 数学函数
379
- *
380
- * @returns {number} 传入数值向上取整后的结果
381
- */
382
- fnCEIL(a: number, b: number): number;
383
- /**
384
- * 开平方,参数 number 为非负数
385
- *
386
- * @example SQRT(num)
387
- * @param {number} num - 要处理的数字
388
- * @namespace 数学函数
389
- *
390
- * @returns {number} 开平方的结果
391
- */
392
- fnSQRT(n: number): number;
393
- /**
394
- * 返回所有参数的平均值,如果只有一个参数且是数组,则计算这个数组内的值
395
- *
396
- * @example AVG(num1, num2, ...numN)
397
- * @param {...number} num - 要处理的数字
398
- * @namespace 数学函数
399
- *
400
- * @returns {number} 所有数值的平均值
401
- */
402
- fnAVG(...args: Array<any>): number;
403
- /**
404
- * 返回数据点与数据均值点之差(数据偏差)的平方和,如果只有一个参数且是数组,则计算这个数组内的值
405
- *
406
- * @example DEVSQ(num1, num2, ...numN)
407
- * @param {...number} num - 要处理的数字
408
- * @namespace 数学函数
409
- *
410
- * @returns {number} 所有数值的平均值
411
- */
412
- fnDEVSQ(...args: Array<any>): number | null;
413
- /**
414
- * 数据点到其算术平均值的绝对偏差的平均值
415
- *
416
- * @example AVEDEV(num1, num2, ...numN)
417
- * @param {...number} num - 要处理的数字
418
- * @namespace 数学函数
419
- *
420
- * @returns {number} 所有数值的平均值
421
- */
422
- fnAVEDEV(...args: Array<any>): number | null;
423
- /**
424
- * 数据点的调和平均值,如果只有一个参数且是数组,则计算这个数组内的值
425
- *
426
- * @example HARMEAN(num1, num2, ...numN)
427
- * @param {...number} num - 要处理的数字
428
- * @namespace 数学函数
429
- *
430
- * @returns {number} 所有数值的平均值
431
- */
432
- fnHARMEAN(...args: Array<any>): number | null;
433
- /**
434
- * 数据集中第 k 个最大值
435
- *
436
- * @example LARGE(array, k)
437
- * @param {array} nums - 要处理的数字
438
- * @param {number} k - 第几大
439
- * @namespace 数学函数
440
- *
441
- * @returns {number} 所有数值的平均值
442
- */
443
- fnLARGE(nums: Array<any>, k: number): any;
444
- /**
445
- * 将数值转为中文大写金额
446
- *
447
- * @example UPPERMONEY(num)
448
- * @param {number} num - 要处理的数字
449
- * @namespace 数学函数
450
- *
451
- * @returns {string} 数值中文大写字符
452
- */
453
- fnUPPERMONEY(n: number): string;
454
- /**
455
- * 返回大于等于 0 且小于 1 的均匀分布随机实数。每一次触发计算都会变化。
456
- *
457
- * 示例:`RAND()*100`
458
- *
459
- * 返回 0-100 之间的随机数
460
- *
461
- * @example RAND()
462
- * @namespace 数学函数
463
- *
464
- * @returns {number} 随机数
465
- */
466
- fnRAND(): number;
467
- /**
468
- * 取数据最后一个
469
- *
470
- * @example LAST(array)
471
- * @param {...number} arr - 要处理的数组
472
- * @namespace 数学函数
473
- *
474
- * @returns {any} 最后一个值
475
- */
476
- fnLAST(arr: Array<any>): any;
477
- normalizeText(raw: any): string;
478
- /**
479
- * 返回传入文本左侧的指定长度字符串。
480
- *
481
- * @example LEFT(text, len)
482
- * @param {string} text - 要处理的文本
483
- * @param {number} len - 要处理的长度
484
- * @namespace 文本函数
485
- *
486
- * @returns {string} 对应字符串
487
- */
488
- fnLEFT(text: string, len: number): string;
489
- /**
490
- * 返回传入文本右侧的指定长度字符串。
491
- *
492
- * @example RIGHT(text, len)
493
- * @param {string} text - 要处理的文本
494
- * @param {number} len - 要处理的长度
495
- * @namespace 文本函数
496
- *
497
- * @returns {string} 对应字符串
498
- */
499
- fnRIGHT(text: string, len: number): string;
500
- /**
501
- * 计算文本的长度
502
- *
503
- * @example LEN(text)
504
- * @param {string} text - 要处理的文本
505
- * @namespace 文本函数
506
- *
507
- * @returns {number} 长度
508
- */
509
- fnLEN(text: string): number;
510
- /**
511
- * 计算文本集合中所有文本的长度
512
- *
513
- * @example LENGTH(textArr)
514
- * @param {string[]} textArr - 要处理的文本集合
515
- * @namespace 文本函数
516
- *
517
- * @returns {number[]} 长度集合
518
- */
519
- fnLENGTH(...args: any[]): any;
520
- /**
521
- * 判断文本是否为空
522
- *
523
- * @example ISEMPTY(text)
524
- * @param {string} text - 要处理的文本
525
- * @namespace 文本函数
526
- *
527
- * @returns {boolean} 判断结果
528
- */
529
- fnISEMPTY(text: string): boolean;
530
- /**
531
- * 将多个传入值连接成文本
532
- *
533
- * @example CONCATENATE(text1, text2, ...textN)
534
- * @param {...string} text - 文本集合
535
- * @namespace 文本函数
536
- *
537
- * @returns {string} 连接后的文本
538
- */
539
- fnCONCATENATE(...args: Array<any>): string;
540
- /**
541
- * 返回计算机字符集的数字代码所对应的字符。
542
- *
543
- * `CHAR(97)` 等价于 "a"
544
- *
545
- * @example CHAR(code)
546
- * @param {number} code - 编码值
547
- * @namespace 文本函数
548
- *
549
- * @returns {string} 指定位置的字符
550
- */
551
- fnCHAR(code: number): string;
552
- /**
553
- * 将传入文本转成小写
554
- *
555
- * @example LOWER(text)
556
- * @param {string} text - 文本
557
- * @namespace 文本函数
558
- *
559
- * @returns {string} 结果文本
560
- */
561
- fnLOWER(text: string): string;
562
- /**
563
- * 将传入文本转成大写
564
- *
565
- * @example UPPER(text)
566
- * @param {string} text - 文本
567
- * @namespace 文本函数
568
- *
569
- * @returns {string} 结果文本
570
- */
571
- fnUPPER(text: string): string;
572
- /**
573
- * 将传入文本首字母转成大写
574
- *
575
- * @example UPPERFIRST(text)
576
- * @param {string} text - 文本
577
- * @namespace 文本函数
578
- *
579
- * @returns {string} 结果文本
580
- */
581
- fnUPPERFIRST(text: string): string;
582
- /**
583
- * 向前补齐文本长度
584
- *
585
- * 示例 `PADSTART("6", 2, "0")`
586
- *
587
- * 返回 `06`
588
- *
589
- * @example PADSTART(text)
590
- * @param {string} text - 文本
591
- * @param {number} num - 目标长度
592
- * @param {string} pad - 用于补齐的文本
593
- * @namespace 文本函数
594
- *
595
- * @returns {string} 结果文本
596
- */
597
- fnPADSTART(text: string, num: number, pad: string): string;
598
- /**
599
- * 将文本转成标题
600
- *
601
- * 示例 `CAPITALIZE("star")`
602
- *
603
- * 返回 `Star`
604
- *
605
- * @example CAPITALIZE(text)
606
- * @param {string} text - 文本
607
- * @namespace 文本函数
608
- *
609
- * @returns {string} 结果文本
610
- */
611
- fnCAPITALIZE(text: string): string;
612
- /**
613
- * 对文本进行 HTML 转义
614
- *
615
- * 示例 `ESCAPE("star")`
616
- *
617
- * 返回 `Star`
618
- *
619
- * @example ESCAPE(text)
620
- * @param {string} text - 文本
621
- * @namespace 文本函数
622
- *
623
- * @returns {string} 结果文本
624
- */
625
- fnESCAPE(text: string): string;
626
- /**
627
- * 对文本长度进行截断
628
- *
629
- * 示例 `TRUNCATE("amis.baidu.com", 6)`
630
- *
631
- * 返回 `amis...`
632
- *
633
- * @example TRUNCATE(text, 6)
634
- * @param {string} text - 文本
635
- * @param {number} text - 最长长度
636
- * @namespace 文本函数
637
- *
638
- * @returns {string} 结果文本
639
- */
640
- fnTRUNCATE(text: string, length: number): string;
641
- /**
642
- * 取在某个分隔符之前的所有字符串
643
- *
644
- * @example BEFORELAST(text, '.')
645
- * @param {string} text - 文本
646
- * @param {string} delimiter - 结束文本
647
- * @namespace 文本函数
648
- *
649
- * @returns {string} 判断结果
650
- */
651
- fnBEFORELAST(text: string, delimiter?: string): string;
652
- /**
653
- * 将文本根据指定片段分割成数组
654
- *
655
- * 示例:`SPLIT("a,b,c", ",")`
656
- *
657
- * 返回 `["a", "b", "c"]`
658
- *
659
- * @example SPLIT(text, ',')
660
- * @param {string} text - 文本
661
- * @param {string} delimiter - 文本片段
662
- * @namespace 文本函数
663
- *
664
- * @returns {Array<string>} 文本集
665
- */
666
- fnSPLIT(text: string, sep?: string): string[];
667
- /**
668
- * 将文本去除前后空格
669
- *
670
- * @example TRIM(text)
671
- * @param {string} text - 文本
672
- * @namespace 文本函数
673
- *
674
- * @returns {string} 处理后的文本
675
- */
676
- fnTRIM(text: string): string;
677
- /**
678
- * 去除文本中的 HTML 标签
679
- *
680
- * 示例:`STRIPTAG("<b>amis</b>")`
681
- *
682
- * 返回:`amis`
683
- *
684
- * @example STRIPTAG(text)
685
- * @param {string} text - 文本
686
- * @namespace 文本函数
687
- *
688
- * @returns {string} 处理后的文本
689
- */
690
- fnSTRIPTAG(text: string): string;
691
- /**
692
- * 将字符串中的换行转成 HTML `<br>`,用于简单换行的场景
693
- *
694
- * 示例:`LINEBREAK("\n")`
695
- *
696
- * 返回:`<br/>`
697
- *
698
- * @example LINEBREAK(text)
699
- * @param {string} text - 文本
700
- * @namespace 文本函数
701
- *
702
- * @returns {string} 处理后的文本
703
- */
704
- fnLINEBREAK(text: string): string;
705
- /**
706
- * 判断字符串(text)是否以特定字符串(startString)开始,是则返回 True,否则返回 False
707
- *
708
- * @example STARTSWITH(text, '片段')
709
- * @param {string} text - 文本
710
- * @param {string} startString - 起始文本
711
- * @namespace 文本函数
712
- *
713
- * @returns {string} 判断结果
714
- */
715
- fnSTARTSWITH(text: string, search: string): boolean;
716
- /**
717
- * 判断字符串(text)是否以特定字符串(endString)结束,是则返回 True,否则返回 False
718
- *
719
- * @example ENDSWITH(text, '片段')
720
- * @param {string} text - 文本
721
- * @param {string} endString - 结束文本
722
- * @namespace 文本函数
723
- *
724
- * @returns {string} 判断结果
725
- */
726
- fnENDSWITH(text: string, search: string): boolean;
727
- /**
728
- * 判断参数 1 中的文本是否包含参数 2 中的文本。
729
- *
730
- * @example CONTAINS(text, searchText)
731
- * @param {string} text - 文本
732
- * @param {string} searchText - 搜索文本
733
- * @namespace 文本函数
734
- *
735
- * @returns {string} 判断结果
736
- */
737
- fnCONTAINS(text: string, search: string): boolean;
738
- /**
739
- * 对文本进行全量替换。
740
- *
741
- * @example REPLACE(text, search, replace)
742
- * @param {string} text - 要处理的文本
743
- * @param {string} search - 要被替换的文本
744
- * @param {string} replace - 要替换的文本
745
- * @namespace 文本函数
746
- *
747
- * @returns {string} 处理结果
748
- */
749
- fnREPLACE(text: string, search: string, replace: string): string;
750
- /**
751
- * 对文本进行搜索,返回命中的位置
752
- *
753
- * @example SEARCH(text, search, 0)
754
- * @param {string} text - 要处理的文本
755
- * @param {string} search - 用来搜索的文本
756
- * @param {number} start - 起始位置
757
- * @namespace 文本函数
758
- *
759
- * @returns {number} 命中的位置
760
- */
761
- fnSEARCH(text: string, search: string, start?: number): number;
762
- /**
763
- * 返回文本字符串中从指定位置开始的特定数目的字符
764
- *
765
- * @example MID(text, from, len)
766
- * @param {string} text - 要处理的文本
767
- * @param {number} from - 起始位置
768
- * @param {number} len - 处理长度
769
- * @namespace 文本函数
770
- *
771
- * @returns {number} 命中的位置
772
- */
773
- fnMID(text: string, from: number, len: number): string;
774
- /**
775
- * 返回路径中的文件名
776
- *
777
- * 示例:`/home/amis/a.json`
778
- *
779
- * 返回:a.json`
780
- *
781
- * @example BASENAME(text)
782
- * @param {string} text - 要处理的文本
783
- * @namespace 文本函数
784
- *
785
- * @returns {string} 文件名
786
- */
787
- fnBASENAME(text: string): string | undefined;
788
- /**
789
- * 创建日期对象,可以通过特定格式的字符串,或者数值。
790
- *
791
- * 需要注意的是,其中月份的数值是从0开始的,也就是说,
792
- * 如果是12月份,你应该传入数值11。
793
- *
794
- * @example DATE(2021, 11, 6, 8, 20, 0)
795
- * @example DATE('2021-12-06 08:20:00')
796
- * @namespace 日期函数
797
- *
798
- * @returns {Date} 日期对象
799
- */
800
- fnDATE(year: number, month: number, day: number, hour: number, minute: number, second: number): Date;
801
- /**
802
- * 返回时间的时间戳
803
- *
804
- * @example TIMESTAMP(date[, format = "X"])
805
- * @namespace 日期函数
806
- * @param {date} date 日期对象
807
- * @param {string} format 时间戳格式,带毫秒传入 'x'。默认为 'X' 不带毫秒的。
808
- *
809
- * @returns {number} 时间戳
810
- */
811
- fnTIMESTAMP(date: Date, format?: 'x' | 'X'): number;
812
- /**
813
- * 返回今天的日期
814
- *
815
- * @example TODAY()
816
- * @namespace 日期函数
817
- *
818
- * @returns {number} 日期
819
- */
820
- fnTODAY(): Date;
821
- /**
822
- * 返回现在的日期
823
- *
824
- * @example NOW()
825
- * @namespace 日期函数
826
- *
827
- * @returns {number} 日期
828
- */
829
- fnNOW(): Date;
830
- /**
831
- * 将日期转成日期字符串
832
- *
833
- * @example DATETOSTR(date[, format="YYYY-MM-DD HH:mm:ss"])
834
- * @namespace 日期函数
835
- * @param {date} date 日期对象
836
- * @param {string} format 日期格式,默认为 "YYYY-MM-DD HH:mm:ss"
837
- *
838
- * @returns {number} 日期字符串
839
- */
840
- fnDATETOSTR(date: Date, format?: string): string;
841
- /**
842
- * 返回日期的指定范围的开端
843
- *
844
- * @namespace 日期函数
845
- * @example STARTOF(date[unit = "day"])
846
- * @param {date} date 日期对象
847
- * @param {string} unit 比如可以传入 'day'、'month'、'year' 或者 `week` 等等
848
- * @returns {date} 新的日期对象
849
- */
850
- fnSTARTOF(date: Date, unit?: any): Date;
851
- /**
852
- * 返回日期的指定范围的末尾
853
- * @namespace 日期函数
854
- * @example ENDOF(date[unit = "day"])
855
- * @param {date} date 日期对象
856
- * @param {string} unit 比如可以传入 'day'、'month'、'year' 或者 `week` 等等
857
- * @returns {date} 新的日期对象
858
- */
859
- fnENDOF(date: Date, unit?: any): Date;
860
- normalizeDate(raw: any): Date;
861
- /**
862
- * 返回日期的年份
863
- * @namespace 日期函数
864
- * @example YEAR(date)
865
- * @param {date} date 日期对象
866
- * @returns {number} 数值
867
- */
868
- fnYEAR(date: Date): number;
869
- /**
870
- * 返回日期的月份,这里就是自然月份。
871
- *
872
- * @namespace 日期函数
873
- * @example MONTH(date)
874
- * @param {date} date 日期对象
875
- * @returns {number} 数值
876
- */
877
- fnMONTH(date: Date): number;
878
- /**
879
- * 返回日期的天
880
- * @namespace 日期函数
881
- * @example DAY(date)
882
- * @param {date} date 日期对象
883
- * @returns {number} 数值
884
- */
885
- fnDAY(date: Date): number;
886
- /**
887
- * 返回日期的小时
888
- * @param {date} date 日期对象
889
- * @namespace 日期函数
890
- * @example HOUR(date)
891
- * @returns {number} 数值
892
- */
893
- fnHOUR(date: Date): number;
894
- /**
895
- * 返回日期的分
896
- * @param {date} date 日期对象
897
- * @namespace 日期函数
898
- * @example MINUTE(date)
899
- * @returns {number} 数值
900
- */
901
- fnMINUTE(date: Date): number;
902
- /**
903
- * 返回日期的秒
904
- * @param {date} date 日期对象
905
- * @namespace 日期函数
906
- * @example SECOND(date)
907
- * @returns {number} 数值
908
- */
909
- fnSECOND(date: Date): number;
910
- /**
911
- * 返回两个日期相差多少年
912
- * @param {date} endDate 日期对象
913
- * @param {date} startDate 日期对象
914
- * @namespace 日期函数
915
- * @example YEARS(endDate, startDate)
916
- * @returns {number} 数值
917
- */
918
- fnYEARS(endDate: Date, startDate: Date): number;
919
- /**
920
- * 返回两个日期相差多少分钟
921
- * @param {date} endDate 日期对象
922
- * @param {date} startDate 日期对象
923
- * @namespace 日期函数
924
- * @example MINUTES(endDate, startDate)
925
- * @returns {number} 数值
926
- */
927
- fnMINUTES(endDate: Date, startDate: Date): number;
928
- /**
929
- * 返回两个日期相差多少天
930
- * @param {date} endDate 日期对象
931
- * @param {date} startDate 日期对象
932
- * @namespace 日期函数
933
- * @example DAYS(endDate, startDate)
934
- * @returns {number} 数值
935
- */
936
- fnDAYS(endDate: Date, startDate: Date): number;
937
- /**
938
- * 返回两个日期相差多少小时
939
- * @param {date} endDate 日期对象
940
- * @param {date} startDate 日期对象
941
- * @namespace 日期函数
942
- * @example HOURS(endDate, startDate)
943
- * @returns {number} 数值
944
- */
945
- fnHOURS(endDate: Date, startDate: Date): number;
946
- /**
947
- * 修改日期,对日期进行加减天、月份、年等操作
948
- *
949
- * 示例:
950
- *
951
- * DATEMODIFY(A, -2, 'month')
952
- *
953
- * 对日期 A 进行往前减2月的操作。
954
- *
955
- * @param {date} date 日期对象
956
- * @param {number} num 数值
957
- * @param {string} unit 单位:支持年、月、天等等
958
- * @namespace 日期函数
959
- * @example DATEMODIFY(date, 2, 'days')
960
- * @returns {date} 日期对象
961
- */
962
- fnDATEMODIFY(date: Date, num: number, format: any): Date;
963
- /**
964
- * 将字符日期转成日期对象,可以指定日期格式。
965
- *
966
- * 示例:STRTODATE('2021/12/6', 'YYYY/MM/DD')
967
- *
968
- * @param {string} value 日期字符
969
- * @param {string} format 日期格式
970
- * @namespace 日期函数
971
- * @example STRTODATE(value[, format=""])
972
- * @returns {date} 日期对象
973
- */
974
- fnSTRTODATE(value: any, format?: string): Date;
975
- /**
976
- * 判断两个日期,是否第一个日期在第二个日期的前面
977
- *
978
- * @param {date} a 第一个日期
979
- * @param {date} b 第二个日期
980
- * @param {string} unit 单位,默认是 'day', 即之比较到天
981
- * @namespace 日期函数
982
- * @example ISBEFORE(a, b)
983
- * @returns {boolean} 判断结果
984
- */
985
- fnISBEFORE(a: Date, b: Date, unit?: any): boolean;
986
- /**
987
- * 判断两个日期,是否第一个日期在第二个日期的后面
988
- *
989
- * @param {date} a 第一个日期
990
- * @param {date} b 第二个日期
991
- * @param {string} unit 单位,默认是 'day', 即之比较到天
992
- * @namespace 日期函数
993
- * @example ISAFTER(a, b)
994
- * @returns {boolean} 判断结果
995
- */
996
- fnISAFTER(a: Date, b: Date, unit?: any): boolean;
997
- /**
998
- * 判断两个日期,是否第一个日期在第二个日期的前面或者相等
999
- *
1000
- * @param {date} a 第一个日期
1001
- * @param {date} b 第二个日期
1002
- * @param {string} unit 单位,默认是 'day', 即之比较到天
1003
- * @namespace 日期函数
1004
- * @example ISSAMEORBEFORE(a, b)
1005
- * @returns {boolean} 判断结果
1006
- */
1007
- fnISSAMEORBEFORE(a: Date, b: Date, unit?: any): boolean;
1008
- /**
1009
- * 判断两个日期,是否第一个日期在第二个日期的后面或者相等
1010
- *
1011
- * @param {date} a 第一个日期
1012
- * @param {date} b 第二个日期
1013
- * @param {string} unit 单位,默认是 'day', 即之比较到天
1014
- * @namespace 日期函数
1015
- * @example ISSAMEORAFTER(a, b)
1016
- * @returns {boolean} 判断结果
1017
- */
1018
- fnISSAMEORAFTER(a: Date, b: Date, unit?: any): boolean;
1019
- /**
1020
- * 返回数组的长度
1021
- *
1022
- * @param {Array<any>} arr 数组
1023
- * @namespace 数组
1024
- * @example COUNT(arr)
1025
- * @returns {boolean} 结果
1026
- */
1027
- fnCOUNT(value: any): number;
1028
- /**
1029
- * 数组做数据转换,需要搭配箭头函数一起使用,注意箭头函数只支持单表达式用法。
1030
- *
1031
- * @param {Array<any>} arr 数组
1032
- * @param {Function<any>} iterator 箭头函数
1033
- * @namespace 数组
1034
- * @example ARRAYMAP(arr, item => item)
1035
- * @returns {boolean} 结果
1036
- */
1037
- fnARRAYMAP(value: any, iterator: any): any[];
1038
- /**
1039
- * 数组过滤掉 false、null、0 和 ""
1040
- *
1041
- * 示例:
1042
- *
1043
- * COMPACT([0, 1, false, 2, '', 3]) 得到 [1, 2, 3]
1044
- *
1045
- * @param {Array<any>} arr 数组
1046
- * @namespace 数组
1047
- * @example COMPACT(arr)
1048
- * @returns {Array<any>} 结果
1049
- */
1050
- fnCOMPACT(arr: any[]): any[];
1051
- /**
1052
- * 数组转成字符串
1053
- *
1054
- * 示例:
1055
- *
1056
- * JOIN(['a', 'b', 'c'], '~') 得到 'a~b~c'
1057
- *
1058
- * @param {Array<any>} arr 数组
1059
- * @param { String} separator 分隔符
1060
- * @namespace 数组
1061
- * @example JOIN(arr, string)
1062
- * @returns {String} 结果
1063
- */
1064
- fnJOIN(arr: any[], separator?: string): string;
1065
- }
1066
- export declare function createObject(superProps?: {
1067
- [propName: string]: any;
1068
- }, props?: {
1069
- [propName: string]: any;
1070
- }, properties?: any): object;
package/dist/filter.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { FilterMap } from './types';
2
- /**
3
- * filter 是历史包袱,不建议使用。因为这是之前的语法,所以在公式解析里面做了兼容。
4
- * 建议用 ${ LEFT(xxx) } 这种函数调用语法。
5
- */
6
- export declare const filters: FilterMap;
7
- export declare function registerFilter(name: string, fn: (input: any, ...args: any[]) => any): void;
8
- export declare function extendsFilters(value: FilterMap): void;
9
- export declare function getFilters(): FilterMap;
package/dist/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { Evaluator } from './evalutor';
2
- import { parse } from './parser';
3
- import { lexer } from './lexer';
4
- import { registerFilter, filters, getFilters, extendsFilters } from './filter';
5
- import type { FilterContext, ASTNode, ParserOptions, EvaluatorOptions } from './types';
6
- export { parse, lexer, Evaluator, FilterContext, filters, getFilters, registerFilter, extendsFilters };
7
- export declare function evaluate(astOrString: string | ASTNode, data: any, options?: ParserOptions & EvaluatorOptions): any;
package/dist/lexer.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import { LexerOptions, Token, TokenTypeName } from './types';
2
- export declare const enum TokenEnum {
3
- BooleanLiteral = 1,
4
- RAW = 2,
5
- Variable = 3,
6
- OpenScript = 4,
7
- CloseScript = 5,
8
- EOF = 6,
9
- Identifier = 7,
10
- Literal = 8,
11
- NumericLiteral = 9,
12
- Punctuator = 10,
13
- StringLiteral = 11,
14
- RegularExpression = 12,
15
- TemplateRaw = 13,
16
- TemplateLeftBrace = 14,
17
- TemplateRightBrace = 15,
18
- OpenFilter = 16,
19
- Char = 17
20
- }
21
- export declare const TokenName: {
22
- [propName: string]: TokenTypeName;
23
- };
24
- export declare function lexer(input: string, options?: LexerOptions): {
25
- next: () => Token;
26
- };
package/dist/parser.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { ParserOptions, ASTNode } from './types';
2
- export declare function parse(input: string, options?: ParserOptions): ASTNode;
package/dist/types.d.ts DELETED
@@ -1,83 +0,0 @@
1
- import { Evaluator } from './evalutor';
2
- export interface FilterMap {
3
- [propName: string]: (this: FilterContext, input: any, ...args: any[]) => any;
4
- }
5
- export interface FunctionMap {
6
- [propName: string]: (this: Evaluator, ast: Object, data: any) => any;
7
- }
8
- export interface FilterContext {
9
- data: Object;
10
- filter?: {
11
- name: string;
12
- args: Array<any>;
13
- };
14
- restFilters: Array<{
15
- name: string;
16
- args: Array<any>;
17
- }>;
18
- }
19
- export interface EvaluatorOptions {
20
- /**
21
- * 可以外部传入 ast 节点处理器,定制或者扩充自定义函数
22
- */
23
- functions?: FunctionMap;
24
- /**
25
- * 可以外部扩充 filter
26
- */
27
- filters?: FilterMap;
28
- defaultFilter?: string;
29
- }
30
- export interface LexerOptions {
31
- /**
32
- * 直接是运算表达式?还是从模板开始 ${} 里面才算运算表达式
33
- */
34
- evalMode?: boolean;
35
- /**
36
- * 只支持取变量。
37
- */
38
- variableMode?: boolean;
39
- /**
40
- * 是否允许 filter 语法,比如:
41
- *
42
- * ${abc | html}
43
- */
44
- allowFilter?: boolean;
45
- }
46
- export declare type TokenTypeName = 'Boolean' | 'Raw' | 'Variable' | 'OpenScript' | 'CloseScript' | 'EOF' | 'Identifier' | 'Literal' | 'Numeric' | 'Punctuator' | 'String' | 'RegularExpression' | 'TemplateRaw' | 'TemplateLeftBrace' | 'TemplateRightBrace' | 'OpenFilter' | 'Char';
47
- export interface Position {
48
- index: number;
49
- line: number;
50
- column: number;
51
- }
52
- export interface Token {
53
- type: TokenTypeName;
54
- value: any;
55
- raw?: string;
56
- start: Position;
57
- end: Position;
58
- }
59
- export declare type NodeType = 'content' | 'raw' | 'conditional';
60
- export interface ParserOptions {
61
- /**
62
- * 直接是运算表达式?还是从模板开始 ${} 里面才算运算表达式
63
- */
64
- evalMode?: boolean;
65
- /**
66
- * 只支持取变量。
67
- */
68
- variableMode?: boolean;
69
- /**
70
- * 是否允许 filter 语法,比如:
71
- *
72
- * ${abc | html}
73
- */
74
- allowFilter?: boolean;
75
- variableNamespaces?: Array<string>;
76
- }
77
- export interface ASTNode {
78
- type: string;
79
- start: Position;
80
- end: Position;
81
- [propname: string]: any;
82
- }
83
- export declare type ASTNodeOrNull = ASTNode | null;