@borgar/fx 4.13.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-BMr6cTgc.d.cts +1444 -0
- package/dist/index-BMr6cTgc.d.ts +1444 -0
- package/dist/index.cjs +3054 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2984 -0
- package/dist/index.js.map +1 -0
- package/dist/xlsx/index.cjs +3120 -0
- package/dist/xlsx/index.cjs.map +1 -0
- package/dist/xlsx/index.d.cts +55 -0
- package/dist/xlsx/index.d.ts +55 -0
- package/dist/xlsx/index.js +3049 -0
- package/dist/xlsx/index.js.map +1 -0
- package/docs/API.md +2959 -718
- package/docs/AST_format.md +2 -2
- package/eslint.config.mjs +40 -0
- package/lib/a1.spec.ts +32 -0
- package/lib/a1.ts +26 -0
- package/lib/addA1RangeBounds.ts +50 -0
- package/lib/addTokenMeta.spec.ts +166 -0
- package/lib/{addTokenMeta.js → addTokenMeta.ts} +53 -33
- package/lib/astTypes.ts +211 -0
- package/lib/cloneToken.ts +29 -0
- package/lib/{constants.js → constants.ts} +6 -3
- package/lib/fixRanges.spec.ts +220 -0
- package/lib/fixRanges.ts +260 -0
- package/lib/fromCol.spec.ts +15 -0
- package/lib/{fromCol.js → fromCol.ts} +1 -1
- package/lib/index.spec.ts +119 -0
- package/lib/index.ts +76 -0
- package/lib/isNodeType.ts +151 -0
- package/lib/isType.spec.ts +208 -0
- package/lib/{isType.js → isType.ts} +26 -25
- package/lib/lexers/{advRangeOp.js → advRangeOp.ts} +1 -1
- package/lib/lexers/{canEndRange.js → canEndRange.ts} +2 -2
- package/lib/lexers/{lexBoolean.js → lexBoolean.ts} +25 -6
- package/lib/lexers/{lexContext.js → lexContext.ts} +14 -6
- package/lib/lexers/{lexError.js → lexError.ts} +3 -3
- package/lib/lexers/{lexFunction.js → lexFunction.ts} +3 -2
- package/lib/lexers/lexNameFuncCntx.ts +112 -0
- package/lib/lexers/{lexNamed.js → lexNamed.ts} +4 -4
- package/lib/lexers/{lexNewLine.js → lexNewLine.ts} +3 -2
- package/lib/lexers/{lexNumber.js → lexNumber.ts} +4 -3
- package/lib/lexers/{lexOperator.js → lexOperator.ts} +5 -4
- package/lib/lexers/lexRange.ts +15 -0
- package/lib/lexers/{lexRangeA1.js → lexRangeA1.ts} +11 -7
- package/lib/lexers/{lexRangeR1C1.js → lexRangeR1C1.ts} +10 -6
- package/lib/lexers/{lexRangeTrim.js → lexRangeTrim.ts} +3 -2
- package/lib/lexers/{lexRefOp.js → lexRefOp.ts} +4 -3
- package/lib/lexers/{lexString.js → lexString.ts} +3 -3
- package/lib/lexers/{lexStructured.js → lexStructured.ts} +5 -5
- package/lib/lexers/{lexWhitespace.js → lexWhitespace.ts} +3 -2
- package/lib/lexers/sets.ts +51 -0
- package/lib/mergeRefTokens.spec.ts +141 -0
- package/lib/{mergeRefTokens.js → mergeRefTokens.ts} +14 -9
- package/lib/nodeTypes.ts +54 -0
- package/lib/parse.spec.ts +1410 -0
- package/lib/{parser.js → parse.ts} +81 -63
- package/lib/parseA1Range.spec.ts +233 -0
- package/lib/parseA1Range.ts +206 -0
- package/lib/parseA1Ref.spec.ts +337 -0
- package/lib/parseA1Ref.ts +115 -0
- package/lib/parseR1C1Range.ts +191 -0
- package/lib/parseR1C1Ref.spec.ts +323 -0
- package/lib/parseR1C1Ref.ts +127 -0
- package/lib/parseRef.spec.ts +90 -0
- package/lib/parseRef.ts +240 -0
- package/lib/{parseSRange.js → parseSRange.ts} +15 -10
- package/lib/parseStructRef.spec.ts +168 -0
- package/lib/parseStructRef.ts +76 -0
- package/lib/stringifyA1Range.spec.ts +72 -0
- package/lib/stringifyA1Range.ts +72 -0
- package/lib/stringifyA1Ref.spec.ts +64 -0
- package/lib/stringifyA1Ref.ts +59 -0
- package/lib/{stringifyPrefix.js → stringifyPrefix.ts} +17 -2
- package/lib/stringifyR1C1Range.spec.ts +92 -0
- package/lib/stringifyR1C1Range.ts +73 -0
- package/lib/stringifyR1C1Ref.spec.ts +63 -0
- package/lib/stringifyR1C1Ref.ts +67 -0
- package/lib/stringifyStructRef.spec.ts +124 -0
- package/lib/stringifyStructRef.ts +113 -0
- package/lib/stringifyTokens.ts +15 -0
- package/lib/toCol.spec.ts +11 -0
- package/lib/{toCol.js → toCol.ts} +4 -4
- package/lib/tokenTypes.ts +76 -0
- package/lib/tokenize-srefs.spec.ts +429 -0
- package/lib/tokenize.spec.ts +2103 -0
- package/lib/tokenize.ts +346 -0
- package/lib/translate.spec.ts +35 -0
- package/lib/translateToA1.spec.ts +247 -0
- package/lib/translateToA1.ts +231 -0
- package/lib/translateToR1C1.spec.ts +227 -0
- package/lib/translateToR1C1.ts +145 -0
- package/lib/types.ts +179 -0
- package/lib/xlsx/index.spec.ts +27 -0
- package/lib/xlsx/index.ts +32 -0
- package/package.json +45 -31
- package/tsconfig.json +28 -0
- package/typedoc-ignore-links.ts +17 -0
- package/typedoc.json +41 -0
- package/.eslintrc +0 -22
- package/benchmark/benchmark.js +0 -48
- package/benchmark/formulas.json +0 -15677
- package/dist/fx.d.ts +0 -823
- package/dist/fx.js +0 -2
- package/dist/package.json +0 -1
- package/lib/a1.js +0 -348
- package/lib/a1.spec.js +0 -458
- package/lib/addTokenMeta.spec.js +0 -153
- package/lib/astTypes.js +0 -96
- package/lib/extraTypes.js +0 -74
- package/lib/fixRanges.js +0 -104
- package/lib/fixRanges.spec.js +0 -171
- package/lib/fromCol.spec.js +0 -11
- package/lib/index.js +0 -134
- package/lib/index.spec.js +0 -67
- package/lib/isType.spec.js +0 -168
- package/lib/lexer-srefs.spec.js +0 -324
- package/lib/lexer.js +0 -264
- package/lib/lexer.spec.js +0 -1953
- package/lib/lexers/lexRange.js +0 -8
- package/lib/lexers/sets.js +0 -38
- package/lib/mergeRefTokens.spec.js +0 -121
- package/lib/package.json +0 -1
- package/lib/parseRef.js +0 -157
- package/lib/parseRef.spec.js +0 -71
- package/lib/parseStructRef.js +0 -48
- package/lib/parseStructRef.spec.js +0 -164
- package/lib/parser.spec.js +0 -1208
- package/lib/rc.js +0 -341
- package/lib/rc.spec.js +0 -403
- package/lib/stringifyStructRef.js +0 -80
- package/lib/stringifyStructRef.spec.js +0 -182
- package/lib/toCol.spec.js +0 -11
- package/lib/translate-toA1.spec.js +0 -214
- package/lib/translate-toRC.spec.js +0 -197
- package/lib/translate.js +0 -239
- package/lib/translate.spec.js +0 -21
- package/rollup.config.mjs +0 -22
- package/tsd.json +0 -12
package/dist/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "type": "commonjs" }
|
package/lib/a1.js
DELETED
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import { MAX_ROWS, MAX_COLS } from './constants.js';
|
|
2
|
-
import { parseRef } from './parseRef.js';
|
|
3
|
-
import { toCol } from './toCol.js';
|
|
4
|
-
import { fromCol } from './fromCol.js';
|
|
5
|
-
import { stringifyPrefix, stringifyPrefixAlt } from './stringifyPrefix.js';
|
|
6
|
-
|
|
7
|
-
const clamp = (min, val, max) => Math.min(Math.max(val, min), max);
|
|
8
|
-
const toColStr = (c, a) => (a ? '$' : '') + toCol(c);
|
|
9
|
-
const toRowStr = (r, a) => (a ? '$' : '') + toRow(r);
|
|
10
|
-
|
|
11
|
-
export function fromRow (rowStr) {
|
|
12
|
-
return +rowStr - 1;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function toRow (top) {
|
|
16
|
-
return String(top + 1);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function toRelative (range) {
|
|
20
|
-
return Object.assign({}, range, { $left: false, $right: false, $top: false, $bottom: false });
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function toAbsolute (range) {
|
|
24
|
-
return Object.assign({}, range, { $left: true, $right: true, $top: true, $bottom: true });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @ignore
|
|
29
|
-
* @param {'head' | 'tail' | 'both' | null | undefined} trim Does the range have trimming?
|
|
30
|
-
* @returns {string} The appropriate range join operator
|
|
31
|
-
*/
|
|
32
|
-
export function rangeOperator (trim) {
|
|
33
|
-
if (trim === 'both') {
|
|
34
|
-
return '.:.';
|
|
35
|
-
}
|
|
36
|
-
else if (trim === 'head') {
|
|
37
|
-
return '.:';
|
|
38
|
-
}
|
|
39
|
-
else if (trim === 'tail') {
|
|
40
|
-
return ':.';
|
|
41
|
-
}
|
|
42
|
-
return ':';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function trimDirection (head, tail) {
|
|
46
|
-
if (head && tail) {
|
|
47
|
-
return 'both';
|
|
48
|
-
}
|
|
49
|
-
if (head) {
|
|
50
|
-
return 'head';
|
|
51
|
-
}
|
|
52
|
-
if (tail) {
|
|
53
|
-
return 'tail';
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Stringify a range object into A1 syntax.
|
|
59
|
-
*
|
|
60
|
-
* @private
|
|
61
|
-
* @ignore
|
|
62
|
-
* @see parseA1Ref
|
|
63
|
-
* @param {RangeA1} range A range object
|
|
64
|
-
* @returns {string} An A1-style string represenation of a range
|
|
65
|
-
*/
|
|
66
|
-
export function toA1 (range) {
|
|
67
|
-
// eslint-disable-next-line prefer-const
|
|
68
|
-
let { top, left, bottom, right, trim } = range;
|
|
69
|
-
const { $left, $right, $top, $bottom } = range;
|
|
70
|
-
const noLeft = left == null;
|
|
71
|
-
const noRight = right == null;
|
|
72
|
-
const noTop = top == null;
|
|
73
|
-
const noBottom = bottom == null;
|
|
74
|
-
// allow skipping right and bottom to define a cell
|
|
75
|
-
top = clamp(0, top | 0, MAX_ROWS);
|
|
76
|
-
left = clamp(0, left | 0, MAX_COLS);
|
|
77
|
-
if (!noLeft && !noTop && noRight && noBottom) {
|
|
78
|
-
bottom = top;
|
|
79
|
-
right = left;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
bottom = clamp(0, bottom | 0, MAX_ROWS);
|
|
83
|
-
right = clamp(0, right | 0, MAX_COLS);
|
|
84
|
-
}
|
|
85
|
-
const op = rangeOperator(trim);
|
|
86
|
-
// A:A
|
|
87
|
-
const allRows = top === 0 && bottom >= MAX_ROWS;
|
|
88
|
-
const haveAbsCol = ($left && !noLeft) || ($right && !noRight);
|
|
89
|
-
if ((allRows && !noLeft && !noRight && (!haveAbsCol || left === right)) || (noTop && noBottom)) {
|
|
90
|
-
return toColStr(left, $left) + op + toColStr(right, $right);
|
|
91
|
-
}
|
|
92
|
-
// 1:1
|
|
93
|
-
const allCols = left === 0 && right >= MAX_COLS;
|
|
94
|
-
const haveAbsRow = ($top && !noTop) || ($bottom && !noBottom);
|
|
95
|
-
if ((allCols && !noTop && !noBottom && (!haveAbsRow || top === bottom)) || (noLeft && noRight)) {
|
|
96
|
-
return toRowStr(top, $top) + op + toRowStr(bottom, $bottom);
|
|
97
|
-
}
|
|
98
|
-
// A1:1
|
|
99
|
-
if (!noLeft && !noTop && !noRight && noBottom) {
|
|
100
|
-
return toColStr(left, $left) + toRowStr(top, $top) + op + toColStr(right, $right);
|
|
101
|
-
}
|
|
102
|
-
// A:A1 => A1:1
|
|
103
|
-
if (!noLeft && noTop && !noRight && !noBottom) {
|
|
104
|
-
return toColStr(left, $left) + toRowStr(bottom, $bottom) + op + toColStr(right, $right);
|
|
105
|
-
}
|
|
106
|
-
// A1:A
|
|
107
|
-
if (!noLeft && !noTop && noRight && !noBottom) {
|
|
108
|
-
return toColStr(left, $left) + toRowStr(top, $top) + op + toRowStr(bottom, $bottom);
|
|
109
|
-
}
|
|
110
|
-
// A:A1 => A1:A
|
|
111
|
-
if (noLeft && !noTop && !noRight && !noBottom) {
|
|
112
|
-
return toColStr(right, $right) + toRowStr(top, $top) + op + toRowStr(bottom, $bottom);
|
|
113
|
-
}
|
|
114
|
-
// A1:A1
|
|
115
|
-
if (right !== left || bottom !== top || $right !== $left || $bottom !== $top) {
|
|
116
|
-
return toColStr(left, $left) + toRowStr(top, $top) + op +
|
|
117
|
-
toColStr(right, $right) + toRowStr(bottom, $bottom);
|
|
118
|
-
}
|
|
119
|
-
// A1
|
|
120
|
-
return toColStr(left, $left) + toRowStr(top, $top);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function splitA1 (str) {
|
|
124
|
-
const m = /^(?=.)(\$(?=\D))?([A-Za-z]{0,3})?(\$)?([1-9][0-9]{0,6})?$/.exec(str);
|
|
125
|
-
if (!m || (!m[2] && !m[4])) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
return [
|
|
129
|
-
m[4] ? fromRow(m[4]) : null, // row index or null
|
|
130
|
-
m[2] ? fromCol(m[2]) : null, // col index or null
|
|
131
|
-
!!m[3], // is row absolute?
|
|
132
|
-
!!m[1] // is col absolute?
|
|
133
|
-
];
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Parse a simple string reference to an A1 range into a range object.
|
|
138
|
-
* Will accept `A1`, `A2`, `A:A`, or `1:1`.
|
|
139
|
-
*
|
|
140
|
-
* @private
|
|
141
|
-
* @ignore
|
|
142
|
-
* @see parseA1Ref
|
|
143
|
-
* @param {string} rangeString A range string
|
|
144
|
-
* @returns {(RangeA1|null)} An object representing a valid range or null if it is invalid.
|
|
145
|
-
*/
|
|
146
|
-
export function fromA1 (rangeString) {
|
|
147
|
-
let top = null;
|
|
148
|
-
let left = null;
|
|
149
|
-
let bottom = null;
|
|
150
|
-
let right = null;
|
|
151
|
-
let $top = false;
|
|
152
|
-
let $left = false;
|
|
153
|
-
let $bottom = false;
|
|
154
|
-
let $right = false;
|
|
155
|
-
const [ part1, op1, part2, op2, part3 ] = rangeString.split(/(\.?:\.?)/);
|
|
156
|
-
if (op2 || part3) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
const trim = trimDirection(!!op1 && op1[0] === '.', !!op1 && op1[op1.length - 1] === '.');
|
|
160
|
-
const p1 = splitA1(part1);
|
|
161
|
-
const p2 = part2 ? splitA1(part2) : null;
|
|
162
|
-
if (!p1 || (part2 && !p2)) {
|
|
163
|
-
// invalid section
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
// part 1 bits
|
|
167
|
-
if (p1[0] != null && p1[1] != null) {
|
|
168
|
-
[ top, left, $top, $left ] = p1;
|
|
169
|
-
}
|
|
170
|
-
else if (p1[0] == null && p1[1] != null) {
|
|
171
|
-
[ , left, , $left ] = p1;
|
|
172
|
-
}
|
|
173
|
-
else if (p1[0] != null && p1[1] == null) {
|
|
174
|
-
[ top, , $top ] = p1;
|
|
175
|
-
}
|
|
176
|
-
// part 2 bits
|
|
177
|
-
if (!part2) {
|
|
178
|
-
// part 2 must exist if either top or left is null:
|
|
179
|
-
// this disallows a single num or col patterns
|
|
180
|
-
if (top == null || left == null) {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
bottom = top;
|
|
184
|
-
right = left;
|
|
185
|
-
$bottom = $top;
|
|
186
|
-
$right = $left;
|
|
187
|
-
}
|
|
188
|
-
else if (p2[0] != null && p2[1] != null) {
|
|
189
|
-
[ bottom, right, $bottom, $right ] = p2;
|
|
190
|
-
}
|
|
191
|
-
else if (p2[0] == null && p2[1] != null) {
|
|
192
|
-
[ , right, , $right ] = p2;
|
|
193
|
-
}
|
|
194
|
-
else if (p2[0] != null && p2[1] == null) {
|
|
195
|
-
[ bottom, , $bottom ] = p2;
|
|
196
|
-
}
|
|
197
|
-
// flip left/right and top/bottom as needed
|
|
198
|
-
// for partial ranges we perfer the coord on the left-side of the :
|
|
199
|
-
if (right != null && (left == null || (left != null && right < left))) {
|
|
200
|
-
[ left, right, $left, $right ] = [ right, left, $right, $left ];
|
|
201
|
-
}
|
|
202
|
-
if (bottom != null && (top == null || (top != null && bottom < top))) {
|
|
203
|
-
[ top, bottom, $top, $bottom ] = [ bottom, top, $bottom, $top ];
|
|
204
|
-
}
|
|
205
|
-
const r = { top, left, bottom, right, $top, $left, $bottom, $right };
|
|
206
|
-
if (trim) { r.trim = trim; }
|
|
207
|
-
return r;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Parse a string reference into an object representing it.
|
|
212
|
-
*
|
|
213
|
-
* ```js
|
|
214
|
-
* parseA1Ref('Sheet1!A$1:$B2');
|
|
215
|
-
* // => {
|
|
216
|
-
* // context: [ 'Sheet1' ],
|
|
217
|
-
* // range: {
|
|
218
|
-
* // top: 0,
|
|
219
|
-
* // left: 0,
|
|
220
|
-
* // bottom: 1,
|
|
221
|
-
* // right: 1
|
|
222
|
-
* // $top: true,
|
|
223
|
-
* // $left: false,
|
|
224
|
-
* // $bottom: false,
|
|
225
|
-
* // $right: true
|
|
226
|
-
* // }
|
|
227
|
-
* // }
|
|
228
|
-
* ```
|
|
229
|
-
*
|
|
230
|
-
* For A:A or A1:A style ranges, `null` will be used for any dimensions that the
|
|
231
|
-
* syntax does not specify:
|
|
232
|
-
*
|
|
233
|
-
* @param {string} refString An A1-style reference string
|
|
234
|
-
* @param {object} [options={}] Options
|
|
235
|
-
* @param {boolean} [options.allowNamed=true] Enable parsing names as well as ranges.
|
|
236
|
-
* @param {boolean} [options.allowTernary=false] Enables the recognition of ternary ranges in the style of `A1:A` or `A1:1`. These are supported by Google Sheets but not Excel. See: References.md.
|
|
237
|
-
* @param {boolean} [options.xlsx=false] Switches to the `[1]Sheet1!A1` or `[1]!name` prefix syntax form for external workbooks. See: [Prefixes.md](./Prefixes.md)
|
|
238
|
-
* @returns {(ReferenceA1|null)} An object representing a valid reference or null if it is invalid.
|
|
239
|
-
*/
|
|
240
|
-
export function parseA1Ref (refString, { allowNamed = true, allowTernary = false, xlsx = false } = {}) {
|
|
241
|
-
const d = parseRef(refString, { allowNamed, allowTernary, xlsx, r1c1: false });
|
|
242
|
-
if (d && (d.r0 || d.name)) {
|
|
243
|
-
let range = null;
|
|
244
|
-
if (d.r0) {
|
|
245
|
-
range = fromA1(d.r1 ? d.r0 + d.operator + d.r1 : d.r0);
|
|
246
|
-
}
|
|
247
|
-
if (range) {
|
|
248
|
-
return xlsx
|
|
249
|
-
? { workbookName: d.workbookName, sheetName: d.sheetName, range }
|
|
250
|
-
: { context: d.context, range };
|
|
251
|
-
}
|
|
252
|
-
if (d.name) {
|
|
253
|
-
return xlsx
|
|
254
|
-
? { workbookName: d.workbookName, sheetName: d.sheetName, name: d.name }
|
|
255
|
-
: { context: d.context, name: d.name };
|
|
256
|
-
}
|
|
257
|
-
return null;
|
|
258
|
-
}
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Get an A1-style string representation of a reference object.
|
|
264
|
-
*
|
|
265
|
-
* ```js
|
|
266
|
-
* stringifyA1Ref({
|
|
267
|
-
* context: [ 'Sheet1' ],
|
|
268
|
-
* range: {
|
|
269
|
-
* top: 0,
|
|
270
|
-
* left: 0,
|
|
271
|
-
* bottom: 1,
|
|
272
|
-
* right: 1,
|
|
273
|
-
* $top: true,
|
|
274
|
-
* $left: false,
|
|
275
|
-
* $bottom: false,
|
|
276
|
-
* $right: true
|
|
277
|
-
* }
|
|
278
|
-
* });
|
|
279
|
-
* // => 'Sheet1!A$1:$B2'
|
|
280
|
-
* ```
|
|
281
|
-
*
|
|
282
|
-
* @param {ReferenceA1} refObject A reference object
|
|
283
|
-
* @param {object} [options={}] Options
|
|
284
|
-
* @param {boolean} [options.xlsx=false] Switches to the `[1]Sheet1!A1` or `[1]!name` prefix syntax form for external workbooks. See: [Prefixes.md](./Prefixes.md)
|
|
285
|
-
* @returns {string} The reference in A1-style string format
|
|
286
|
-
*/
|
|
287
|
-
export function stringifyA1Ref (refObject, { xlsx = false } = {}) {
|
|
288
|
-
const prefix = xlsx
|
|
289
|
-
? stringifyPrefixAlt(refObject)
|
|
290
|
-
: stringifyPrefix(refObject);
|
|
291
|
-
return prefix + (
|
|
292
|
-
refObject.name ? refObject.name : toA1(refObject.range)
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Fill the any missing bounds in range objects. Top will be set to 0, bottom to
|
|
298
|
-
* 1048575, left to 0, and right to 16383, if they are `null` or `undefined`.
|
|
299
|
-
*
|
|
300
|
-
* ```js
|
|
301
|
-
* addA1RangeBounds({
|
|
302
|
-
* context: [ 'Sheet1' ],
|
|
303
|
-
* range: {
|
|
304
|
-
* top: 0,
|
|
305
|
-
* left: 0,
|
|
306
|
-
* bottom: 1,
|
|
307
|
-
* $top: true,
|
|
308
|
-
* $left: false,
|
|
309
|
-
* $bottom: false,
|
|
310
|
-
* }
|
|
311
|
-
* });
|
|
312
|
-
* // => {
|
|
313
|
-
* // context: [ 'Sheet1' ],
|
|
314
|
-
* // range: {
|
|
315
|
-
* // top: 0,
|
|
316
|
-
* // left: 0,
|
|
317
|
-
* // bottom: 1,
|
|
318
|
-
* // right: 16383,
|
|
319
|
-
* // $top: true,
|
|
320
|
-
* // $left: false,
|
|
321
|
-
* // $bottom: false,
|
|
322
|
-
* // $right: false
|
|
323
|
-
* // }
|
|
324
|
-
* // }
|
|
325
|
-
* ```
|
|
326
|
-
*
|
|
327
|
-
* @param {RangeA1} range The range part of a reference object.
|
|
328
|
-
* @returns {RangeA1} same range with missing bounds filled in.
|
|
329
|
-
*/
|
|
330
|
-
export function addA1RangeBounds (range) {
|
|
331
|
-
if (range.top == null) {
|
|
332
|
-
range.top = 0;
|
|
333
|
-
range.$top = false;
|
|
334
|
-
}
|
|
335
|
-
if (range.bottom == null) {
|
|
336
|
-
range.bottom = MAX_ROWS;
|
|
337
|
-
range.$bottom = false;
|
|
338
|
-
}
|
|
339
|
-
if (range.left == null) {
|
|
340
|
-
range.left = 0;
|
|
341
|
-
range.$left = false;
|
|
342
|
-
}
|
|
343
|
-
if (range.right == null) {
|
|
344
|
-
range.right = MAX_COLS;
|
|
345
|
-
range.$right = false;
|
|
346
|
-
}
|
|
347
|
-
return range;
|
|
348
|
-
}
|