@univerjs/engine-formula 0.2.8 → 0.2.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.
@@ -121,16 +121,22 @@ export declare function strip(num: number, precision?: number): number;
121
121
  * @param right
122
122
  * @returns
123
123
  */
124
- export declare function withinErrorMargin(left: number, right: number): boolean;
124
+ export declare function withinErrorMargin(left: number, right: number, tolerance?: number): boolean;
125
125
  /**
126
126
  * Tolerance for the results of accuracy issues to tolerate certain errors
127
127
  *
128
- * Why 12?
128
+ * Why is precision 12?
129
129
  This is an empirical choice. Generally, choosing 12 can solve most of the 0001 and 0009 problems. e.g. floor(5,1.23) = 0.0800000000000001
130
+
131
+ why is tolerance 1e-10?
132
+ Since the value of Number.EPSILON is too small to be applicable to all floating-point precision processing, for most application scenarios, the error range of 1e-10 can tolerate common floating-point errors.
133
+ For example, =30.2 - 30 displayed as 0.2 in Excel
130
134
  * @param num
135
+ * @param precision
136
+ * @param tolerance
131
137
  * @returns
132
138
  */
133
- export declare function stripErrorMargin(num: number, precision?: number): number;
139
+ export declare function stripErrorMargin(num: number, precision?: number, tolerance?: number): number;
134
140
  /**
135
141
  * Get the fractional part of the number
136
142
  * @param num
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -0,0 +1,10 @@
1
+ import { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
2
+ import { BaseValueObject } from '../../../engine/value-object/base-value-object';
3
+ import { BaseFunction } from '../../base-function';
4
+ export declare class Rank extends BaseFunction {
5
+ minParams: number;
6
+ maxParams: number;
7
+ needsReferenceObject: boolean;
8
+ calculate(number: FunctionVariantType, ref: FunctionVariantType, order?: FunctionVariantType): BaseValueObject;
9
+ private _checkRefReferenceObject;
10
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -0,0 +1,11 @@
1
+ import { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
2
+ import { BaseValueObject } from '../../../engine/value-object/base-value-object';
3
+ import { BaseFunction } from '../../base-function';
4
+ export declare class RankAvg extends BaseFunction {
5
+ minParams: number;
6
+ maxParams: number;
7
+ needsReferenceObject: boolean;
8
+ calculate(number: FunctionVariantType, ref: FunctionVariantType, order?: FunctionVariantType): BaseValueObject;
9
+ private _getResult;
10
+ private _checkRefReferenceObject;
11
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -0,0 +1,10 @@
1
+ import { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
2
+ import { BaseValueObject } from '../../../engine/value-object/base-value-object';
3
+ import { BaseFunction } from '../../base-function';
4
+ export declare class RankEq extends BaseFunction {
5
+ minParams: number;
6
+ maxParams: number;
7
+ needsReferenceObject: boolean;
8
+ calculate(number: FunctionVariantType, ref: FunctionVariantType, order?: FunctionVariantType): BaseValueObject;
9
+ private _checkRefReferenceObject;
10
+ }
@@ -81,15 +81,34 @@ export { FormulaExecutedStateType, type IAllRuntimeData } from './services/runti
81
81
  export { isReferenceString } from './basics/regex';
82
82
  export { matchRefDrawToken } from './basics/match-token';
83
83
  export { IDefinedNamesService, DefinedNamesService, type IDefinedNamesServiceParam, type IDefinedNameMapItem } from './services/defined-names.service';
84
- export { isFormulaTransformable, transformFormula } from './engine/utils/relative-formula';
85
84
  export { IFormulaRuntimeService, FormulaRuntimeService } from './services/runtime.service';
86
85
  export { IFormulaCurrentConfigService, FormulaCurrentConfigService, type IFormulaDirtyData } from './services/current-data.service';
87
86
  export { IActiveDirtyManagerService } from './services/active-dirty-manager.service';
87
+ export { ActiveDirtyManagerService } from './services/active-dirty-manager.service';
88
88
  export type { IRangeChange } from './models/formula-data.model';
89
89
  export { handleNumfmtInCell } from './engine/utils/numfmt-kit';
90
90
  export { AsyncArrayObject } from './engine/reference-object/base-reference-object';
91
91
  export { strip, stripErrorMargin } from './engine/utils/math-kit';
92
92
  export { AsyncObject } from './engine/reference-object/base-reference-object';
93
+ export { Lexer } from './engine/analysis/lexer';
94
+ export { FormulaDependencyGenerator } from './engine/dependency/formula-dependency';
95
+ export { ISuperTableService } from './services/super-table.service';
96
+ export { SuperTableService } from './services/super-table.service';
97
+ export { Interpreter } from './engine/interpreter/interpreter';
98
+ export { AstTreeBuilder } from './engine/analysis/parser';
99
+ export { AstRootNodeFactory } from './engine/ast-node/ast-root-node';
100
+ export { FunctionNodeFactory } from './engine/ast-node/function-node';
101
+ export { LambdaNodeFactory } from './engine/ast-node/lambda-node';
102
+ export { LambdaParameterNodeFactory } from './engine/ast-node/lambda-parameter-node';
103
+ export { OperatorNodeFactory } from './engine/ast-node/operator-node';
104
+ export { PrefixNodeFactory } from './engine/ast-node/prefix-node';
105
+ export { ReferenceNodeFactory } from './engine/ast-node/reference-node';
106
+ export { SuffixNodeFactory } from './engine/ast-node/suffix-node';
107
+ export { UnionNodeFactory } from './engine/ast-node/union-node';
108
+ export { ValueNodeFactory } from './engine/ast-node/value-node';
109
+ export { IDependencyManagerService } from './services/dependency-manager.service';
110
+ export { DependencyManagerService } from './services/dependency-manager.service';
111
+ export { CalculateController } from './controller/calculate.controller';
93
112
  export { RegisterFunctionMutation } from './commands/mutations/register-function.mutation';
94
113
  export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation } from './commands/mutations/set-array-formula-data.mutation';
95
114
  export { RemoveDefinedNameMutation, SetDefinedNameMutation, type ISetDefinedNameMutationSearchParam, type ISetDefinedNameMutationParam } from './commands/mutations/set-defined-name.mutation';