@univerjs/engine-formula 0.2.14 → 0.2.15
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/lib/cjs/index.js +2 -2
- package/lib/es/index.js +444 -256
- package/lib/types/engine/utils/compare.d.ts +11 -3
- package/lib/types/engine/value-object/array-value-object.d.ts +12 -1
- package/lib/types/functions/base-function.d.ts +6 -6
- package/lib/types/functions/lookup/xlookup/index.d.ts +8 -2
- package/lib/types/functions/lookup/xmatch/index.d.ts +1 -2
- package/lib/types/functions/math/function-map.d.ts +1 -1
- package/lib/types/functions/text/function-map.d.ts +1 -1
- package/lib/types/functions/text/leftb/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/leftb/index.d.ts +9 -0
- package/lib/types/functions/text/mid/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/mid/index.d.ts +8 -0
- package/lib/types/functions/text/textafter/index.d.ts +2 -1
- package/lib/types/functions/text/textbefore/index.d.ts +2 -1
- package/lib/umd/index.js +2 -2
- package/package.json +6 -6
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { compareToken } from '../../basics/token';
|
|
2
|
+
/**
|
|
3
|
+
* For SearchType
|
|
4
|
+
*/
|
|
2
5
|
export declare enum ArrayBinarySearchType {
|
|
3
|
-
MIN = 0
|
|
6
|
+
MIN = 0,// Ascending order
|
|
4
7
|
MAX = 1
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* For MatchType
|
|
11
|
+
*/
|
|
6
12
|
export declare enum ArrayOrderSearchType {
|
|
7
|
-
NORMAL = 0
|
|
8
|
-
MIN = 1,
|
|
13
|
+
NORMAL = 0,// Exact match.
|
|
14
|
+
MIN = 1,// Exact match. If none found, return the next smaller item.
|
|
9
15
|
MAX = 2
|
|
10
16
|
}
|
|
11
17
|
export declare function getCompare(): (x: string, y: string) => number;
|
|
@@ -14,3 +20,5 @@ export declare function isMatchWildcard(currentValue: string, value: string): bo
|
|
|
14
20
|
export declare function replaceWildcard(value: string): string;
|
|
15
21
|
export declare function compareWithWildcard(currentValue: string, value: string, operator: compareToken): boolean;
|
|
16
22
|
export declare function escapeRegExp(str: string): string;
|
|
23
|
+
export declare function getMatchModeValue(matchModeValue: number): ArrayOrderSearchType;
|
|
24
|
+
export declare function getSearchModeValue(searchModeValue: number): ArrayBinarySearchType;
|
|
@@ -117,7 +117,18 @@ export declare class ArrayValueObject extends BaseValueObject {
|
|
|
117
117
|
row: number;
|
|
118
118
|
column: number;
|
|
119
119
|
} | null;
|
|
120
|
-
binarySearch(valueObject: BaseValueObject, searchType?: ArrayBinarySearchType): number | undefined;
|
|
120
|
+
binarySearch(valueObject: BaseValueObject, searchType?: ArrayBinarySearchType, matchType?: ArrayOrderSearchType): number | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* searchType defaults to ascending order
|
|
123
|
+
*
|
|
124
|
+
* matchType defaults to the maximum value less than the search value, which is used for the default matching mode of VLOOKUP/LOOKUP/HLOOKUP.
|
|
125
|
+
* @param valueObject
|
|
126
|
+
* @param searchArray
|
|
127
|
+
* @param positionArray
|
|
128
|
+
* @param searchType
|
|
129
|
+
* @param matchType
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
121
132
|
private _binarySearch;
|
|
122
133
|
sum(): BaseValueObject;
|
|
123
134
|
max(): BaseValueObject;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IRange, Nullable
|
|
1
|
+
import { Disposable, IRange, Nullable } from '@univerjs/core';
|
|
2
|
+
import { ArrayOrderSearchType, ArrayBinarySearchType } from '../engine/utils/compare';
|
|
3
|
+
import { BaseValueObject, ErrorValueObject } from '../engine/value-object/base-value-object';
|
|
4
|
+
import { PrimitiveValueType } from '../engine/value-object/primitive-object';
|
|
2
5
|
import { IFunctionNames } from '../basics/function';
|
|
3
6
|
import { BaseReferenceObject, FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
|
|
4
|
-
import { ArrayBinarySearchType, ArrayOrderSearchType } from '../engine/utils/compare';
|
|
5
7
|
import { ArrayValueObject } from '../engine/value-object/array-value-object';
|
|
6
|
-
import { BaseValueObject, ErrorValueObject } from '../engine/value-object/base-value-object';
|
|
7
|
-
import { PrimitiveValueType } from '../engine/value-object/primitive-object';
|
|
8
8
|
import { IDefinedNameMapItem } from '../services/defined-names.service';
|
|
9
9
|
export declare class BaseFunction extends Disposable {
|
|
10
10
|
private _name;
|
|
@@ -76,13 +76,13 @@ export declare class BaseFunction extends Disposable {
|
|
|
76
76
|
* @param logicValueObject
|
|
77
77
|
*/
|
|
78
78
|
getMatchTypeValue(logicValueObject?: BaseValueObject): number | undefined;
|
|
79
|
-
binarySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayBinarySearchType): BaseValueObject;
|
|
79
|
+
binarySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayBinarySearchType, matchType?: ArrayOrderSearchType): BaseValueObject;
|
|
80
80
|
private _getOneFirstByRaw;
|
|
81
81
|
private _getOneLastByRaw;
|
|
82
82
|
equalSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
|
|
83
83
|
fuzzySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
|
|
84
84
|
orderSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean): BaseValueObject;
|
|
85
|
-
binarySearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, axis?: number, searchType?: ArrayBinarySearchType): ErrorValueObject | ArrayValueObject | undefined;
|
|
85
|
+
binarySearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, axis?: number, searchType?: ArrayBinarySearchType, matchType?: ArrayOrderSearchType): ErrorValueObject | ArrayValueObject | undefined;
|
|
86
86
|
equalSearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
|
|
87
87
|
fuzzySearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
|
|
88
88
|
orderSearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { BaseFunction } from '../../base-function';
|
|
1
2
|
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
|
|
2
3
|
import { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
3
|
-
import { BaseFunction } from '../../base-function';
|
|
4
4
|
export declare class Xlookup extends BaseFunction {
|
|
5
5
|
minParams: number;
|
|
6
6
|
maxParams: number;
|
|
@@ -8,5 +8,11 @@ export declare class Xlookup extends BaseFunction {
|
|
|
8
8
|
private _getResult;
|
|
9
9
|
private _handleExpandObject;
|
|
10
10
|
private _handleSingleObject;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Wildcard matching and binary search cannot appear at the same time
|
|
13
|
+
* @param matchModeValue
|
|
14
|
+
* @param searchModeValue
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
private _checkErrorCombination;
|
|
12
18
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { BaseFunction } from '../../base-function';
|
|
1
2
|
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
|
|
2
3
|
import { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
3
|
-
import { BaseFunction } from '../../base-function';
|
|
4
4
|
export declare class Xmatch extends BaseFunction {
|
|
5
5
|
minParams: number;
|
|
6
6
|
maxParams: number;
|
|
7
7
|
calculate(lookupValue: BaseValueObject, lookupArray: ArrayValueObject, matchMode?: BaseValueObject, searchMode?: BaseValueObject): BaseValueObject;
|
|
8
8
|
private _handleSingleObject;
|
|
9
|
-
private _getSearchModeValue;
|
|
10
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FUNCTION_NAMES_TEXT } from './function-names';
|
|
2
1
|
import { Concat } from './concat';
|
|
3
2
|
import { Concatenate } from './concatenate';
|
|
3
|
+
import { FUNCTION_NAMES_TEXT } from './function-names';
|
|
4
4
|
import { Lower } from './lower';
|
|
5
5
|
import { Textafter } from './textafter';
|
|
6
6
|
import { Textbefore } from './textbefore';
|
|
@@ -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,9 @@
|
|
|
1
|
+
import { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
2
|
+
import { BaseFunction } from '../../base-function';
|
|
3
|
+
export declare class Leftb extends BaseFunction {
|
|
4
|
+
minParams: number;
|
|
5
|
+
maxParams: number;
|
|
6
|
+
calculate(text: BaseValueObject, numBytes?: BaseValueObject): BaseValueObject;
|
|
7
|
+
private _handleSingleText;
|
|
8
|
+
private _sliceByBytes;
|
|
9
|
+
}
|
|
@@ -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,8 @@
|
|
|
1
|
+
import { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
2
|
+
import { BaseFunction } from '../../base-function';
|
|
3
|
+
export declare class Mid extends BaseFunction {
|
|
4
|
+
minParams: number;
|
|
5
|
+
maxParams: number;
|
|
6
|
+
calculate(withinText: BaseValueObject, startNum: BaseValueObject, numChars: BaseValueObject): BaseValueObject;
|
|
7
|
+
private _handleSingleText;
|
|
8
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
|
|
2
1
|
import { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
3
2
|
import { StringValueObject } from '../../../engine/value-object/primitive-object';
|
|
4
3
|
import { BaseFunction } from '../../base-function';
|
|
4
|
+
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
|
|
5
5
|
export declare class Textafter extends BaseFunction {
|
|
6
6
|
minParams: number;
|
|
7
7
|
maxParams: number;
|
|
@@ -9,6 +9,7 @@ export declare class Textafter extends BaseFunction {
|
|
|
9
9
|
private _getResultArray;
|
|
10
10
|
private _checkVariantsError;
|
|
11
11
|
private _getStringValue;
|
|
12
|
+
private _getDelimiterValue;
|
|
12
13
|
private _getVariantsNumberFloorValue;
|
|
13
14
|
private _getResult;
|
|
14
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
|
|
2
1
|
import { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
3
2
|
import { StringValueObject } from '../../../engine/value-object/primitive-object';
|
|
4
3
|
import { BaseFunction } from '../../base-function';
|
|
4
|
+
import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
|
|
5
5
|
export declare class Textbefore extends BaseFunction {
|
|
6
6
|
minParams: number;
|
|
7
7
|
maxParams: number;
|
|
@@ -9,6 +9,7 @@ export declare class Textbefore extends BaseFunction {
|
|
|
9
9
|
private _getResultArray;
|
|
10
10
|
private _checkVariantsError;
|
|
11
11
|
private _getStringValue;
|
|
12
|
+
private _getDelimiterValue;
|
|
12
13
|
private _getVariantsNumberFloorValue;
|
|
13
14
|
private _getResult;
|
|
14
15
|
}
|