microsoft-graph 2.22.0 → 2.22.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/dist/cjs/services/addressManipulation.d.ts +27 -13
- package/dist/cjs/services/addressManipulation.d.ts.map +1 -1
- package/dist/cjs/services/addressManipulation.js +52 -37
- package/dist/esm/services/addressManipulation.d.ts +27 -13
- package/dist/esm/services/addressManipulation.d.ts.map +1 -1
- package/dist/esm/services/addressManipulation.js +52 -37
- package/package.json +1 -1
|
@@ -130,21 +130,35 @@ export declare function countAddressRows(address: Address): number;
|
|
|
130
130
|
*/
|
|
131
131
|
export declare function countAddressColumns(address: Address): number;
|
|
132
132
|
/**
|
|
133
|
-
* Extracts a
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
*
|
|
133
|
+
* Extracts a subrange from a spreadsheet-style A1 range (e.g., "A1:D10"),
|
|
134
|
+
* allowing skip and take semantics on both rows and columns.
|
|
135
|
+
*
|
|
136
|
+
* Supports negative values for `skipRows` and `skipCols` to count from the end.
|
|
137
|
+
* Supports negative values for `takeRows` and `takeCols` to exclude from the end after skipping.
|
|
138
|
+
*
|
|
139
|
+
* @param address - The original range in A1 notation (e.g., "A1:D10").
|
|
140
|
+
* @param skipRows - Number of rows to skip. If negative, skips that many rows from the end. Default is 0.
|
|
141
|
+
* @param takeRows - Number of rows to take after skipping. If negative, excludes that many rows from the end of the remaining rows. Default is Infinity.
|
|
142
|
+
* @param skipCols - Number of columns to skip. If negative, skips that many columns from the end. Default is 0.
|
|
143
|
+
* @param takeCols - Number of columns to take after skipping. If negative, excludes that many columns from the end of the remaining columns. Default is Infinity.
|
|
144
|
+
* @returns A new A1-style range representing the sliced subrange (e.g., "B2:C5").
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* subaddress("A1:D10", -1, 1); // Last row: "A10:D10"
|
|
148
|
+
* subaddress("A1:D10", -2, 1); // Second last row: "A9:D9"
|
|
149
|
+
* subaddress("A1:D10", 0, -1); // All but last row: "A1:D9"
|
|
150
|
+
* subaddress("A1:D10", 0, Infinity, -2, 1); // Second last column: "C1:C10"
|
|
151
|
+
*/
|
|
152
|
+
export declare function subaddress(address: Address, skipRows?: number, takeRows?: number, skipCols?: number, takeCols?: number): Address;
|
|
153
|
+
/**
|
|
154
|
+
* Extracts a subrange from a WorkbookRangeRef using skip/take semantics.
|
|
143
155
|
* @param rangeRef Range reference to extract the sub-range from.
|
|
144
|
-
* @param
|
|
145
|
-
* @param
|
|
156
|
+
* @param skipRows Number of rows to skip. If negative, skips from the end. Default 0.
|
|
157
|
+
* @param takeRows Number of rows to take after skipping. If negative, excludes from the end. Default Infinity.
|
|
158
|
+
* @param skipCols Number of columns to skip. If negative, skips from the end. Default 0.
|
|
159
|
+
* @param takeCols Number of columns to take after skipping. If negative, excludes from the end. Default Infinity.
|
|
146
160
|
* @returns Extracted sub-range reference.
|
|
147
161
|
* @throws InvalidArgumentError if the requested rows or columns exceed the available range.
|
|
148
162
|
*/
|
|
149
|
-
export declare function subrange(rangeRef: WorkbookRangeRef,
|
|
163
|
+
export declare function subrange(rangeRef: WorkbookRangeRef, skipRows?: number, takeRows?: number, skipCols?: number, takeCols?: number): WorkbookRangeRef;
|
|
150
164
|
//# sourceMappingURL=addressManipulation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressManipulation.d.ts","sourceRoot":"","sources":["../../../src/services/addressManipulation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAoB,aAAa,EAAsB,UAAU,EAAmB,MAAM,sBAAsB,CAAC;AAGnJ,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAkBtE,MAAM,MAAM,iBAAiB,GAAG;IAC/B,WAAW,EAAE,aAAa,CAAC;IAC3B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G,MAAM,CAGzD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAG5D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,GAAG,OAAO,CAqC1J;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,GAAG,gBAAgB,CAM3K"}
|
|
@@ -280,56 +280,71 @@ function countAddressColumns(address) {
|
|
|
280
280
|
return (0, addressOffset_ts_1.columnAddressToOffset)(components.endColumn) - (0, addressOffset_ts_1.columnAddressToOffset)(components.startColumn) + 1;
|
|
281
281
|
}
|
|
282
282
|
/**
|
|
283
|
-
* Extracts a
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
283
|
+
* Extracts a subrange from a spreadsheet-style A1 range (e.g., "A1:D10"),
|
|
284
|
+
* allowing skip and take semantics on both rows and columns.
|
|
285
|
+
*
|
|
286
|
+
* Supports negative values for `skipRows` and `skipCols` to count from the end.
|
|
287
|
+
* Supports negative values for `takeRows` and `takeCols` to exclude from the end after skipping.
|
|
288
|
+
*
|
|
289
|
+
* @param address - The original range in A1 notation (e.g., "A1:D10").
|
|
290
|
+
* @param skipRows - Number of rows to skip. If negative, skips that many rows from the end. Default is 0.
|
|
291
|
+
* @param takeRows - Number of rows to take after skipping. If negative, excludes that many rows from the end of the remaining rows. Default is Infinity.
|
|
292
|
+
* @param skipCols - Number of columns to skip. If negative, skips that many columns from the end. Default is 0.
|
|
293
|
+
* @param takeCols - Number of columns to take after skipping. If negative, excludes that many columns from the end of the remaining columns. Default is Infinity.
|
|
294
|
+
* @returns A new A1-style range representing the sliced subrange (e.g., "B2:C5").
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* subaddress("A1:D10", -1, 1); // Last row: "A10:D10"
|
|
298
|
+
* subaddress("A1:D10", -2, 1); // Second last row: "A9:D9"
|
|
299
|
+
* subaddress("A1:D10", 0, -1); // All but last row: "A1:D9"
|
|
300
|
+
* subaddress("A1:D10", 0, Infinity, -2, 1); // Second last column: "C1:C10"
|
|
289
301
|
*/
|
|
290
|
-
function subaddress(address,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
302
|
+
function subaddress(address, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
|
|
303
|
+
const { ax, bx, ay, by } = (0, cartesianAddress_ts_1.addressToCartesian)(address);
|
|
304
|
+
const [startRow, endRow] = slice(ay, by, skipRows, takeRows);
|
|
305
|
+
const [startCol, endCol] = slice(ax, bx, skipCols, takeCols);
|
|
306
|
+
if (startRow < ay || endRow > by || startRow > endRow || startCol < ax || endCol > bx || startCol > endCol) {
|
|
307
|
+
throw new InvalidArgumentError_ts_1.default(`Requested subaddress is out of bounds: rows [${startRow + 1},${endRow + 1}], cols [${startCol + 1},${endCol + 1}] in range.`);
|
|
308
|
+
}
|
|
309
|
+
return (0, cartesianAddress_ts_1.cartesianToAddress)({
|
|
310
|
+
ay: startRow,
|
|
311
|
+
by: endRow,
|
|
312
|
+
ax: startCol,
|
|
313
|
+
bx: endCol,
|
|
314
|
+
});
|
|
315
|
+
function slice(start, end, skip, take) {
|
|
316
|
+
let s = start;
|
|
317
|
+
let e = end;
|
|
318
|
+
if (skip > 0) {
|
|
319
|
+
s = start + skip;
|
|
299
320
|
}
|
|
300
|
-
else if (
|
|
301
|
-
|
|
321
|
+
else if (skip < 0) {
|
|
322
|
+
s = end + skip + 1;
|
|
302
323
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const colCount = bx - ax + 1;
|
|
306
|
-
if (Math.abs(cols) > colCount) {
|
|
307
|
-
throw new InvalidArgumentError_ts_1.default(`Requested columns (${cols}) exceed available columns (${colCount}) in range.`);
|
|
324
|
+
if (!Number.isFinite(take)) {
|
|
325
|
+
// do nothing
|
|
308
326
|
}
|
|
309
|
-
if (
|
|
310
|
-
|
|
327
|
+
else if (take >= 0) {
|
|
328
|
+
e = s + take - 1;
|
|
311
329
|
}
|
|
312
|
-
else if (
|
|
313
|
-
|
|
330
|
+
else if (take < 0) {
|
|
331
|
+
e += take;
|
|
314
332
|
}
|
|
333
|
+
return [s, e];
|
|
315
334
|
}
|
|
316
|
-
return (0, cartesianAddress_ts_1.cartesianToAddress)({
|
|
317
|
-
ay,
|
|
318
|
-
by,
|
|
319
|
-
ax,
|
|
320
|
-
bx,
|
|
321
|
-
});
|
|
322
335
|
}
|
|
323
336
|
/**
|
|
324
|
-
* Extracts a
|
|
337
|
+
* Extracts a subrange from a WorkbookRangeRef using skip/take semantics.
|
|
325
338
|
* @param rangeRef Range reference to extract the sub-range from.
|
|
326
|
-
* @param
|
|
327
|
-
* @param
|
|
339
|
+
* @param skipRows Number of rows to skip. If negative, skips from the end. Default 0.
|
|
340
|
+
* @param takeRows Number of rows to take after skipping. If negative, excludes from the end. Default Infinity.
|
|
341
|
+
* @param skipCols Number of columns to skip. If negative, skips from the end. Default 0.
|
|
342
|
+
* @param takeCols Number of columns to take after skipping. If negative, excludes from the end. Default Infinity.
|
|
328
343
|
* @returns Extracted sub-range reference.
|
|
329
344
|
* @throws InvalidArgumentError if the requested rows or columns exceed the available range.
|
|
330
345
|
*/
|
|
331
|
-
function subrange(rangeRef,
|
|
332
|
-
const address = subaddress(rangeRef.address,
|
|
346
|
+
function subrange(rangeRef, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
|
|
347
|
+
const address = subaddress(rangeRef.address, skipRows, takeRows, skipCols, takeCols);
|
|
333
348
|
return {
|
|
334
349
|
...rangeRef,
|
|
335
350
|
address,
|
|
@@ -130,21 +130,35 @@ export declare function countAddressRows(address: Address): number;
|
|
|
130
130
|
*/
|
|
131
131
|
export declare function countAddressColumns(address: Address): number;
|
|
132
132
|
/**
|
|
133
|
-
* Extracts a
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
*
|
|
133
|
+
* Extracts a subrange from a spreadsheet-style A1 range (e.g., "A1:D10"),
|
|
134
|
+
* allowing skip and take semantics on both rows and columns.
|
|
135
|
+
*
|
|
136
|
+
* Supports negative values for `skipRows` and `skipCols` to count from the end.
|
|
137
|
+
* Supports negative values for `takeRows` and `takeCols` to exclude from the end after skipping.
|
|
138
|
+
*
|
|
139
|
+
* @param address - The original range in A1 notation (e.g., "A1:D10").
|
|
140
|
+
* @param skipRows - Number of rows to skip. If negative, skips that many rows from the end. Default is 0.
|
|
141
|
+
* @param takeRows - Number of rows to take after skipping. If negative, excludes that many rows from the end of the remaining rows. Default is Infinity.
|
|
142
|
+
* @param skipCols - Number of columns to skip. If negative, skips that many columns from the end. Default is 0.
|
|
143
|
+
* @param takeCols - Number of columns to take after skipping. If negative, excludes that many columns from the end of the remaining columns. Default is Infinity.
|
|
144
|
+
* @returns A new A1-style range representing the sliced subrange (e.g., "B2:C5").
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* subaddress("A1:D10", -1, 1); // Last row: "A10:D10"
|
|
148
|
+
* subaddress("A1:D10", -2, 1); // Second last row: "A9:D9"
|
|
149
|
+
* subaddress("A1:D10", 0, -1); // All but last row: "A1:D9"
|
|
150
|
+
* subaddress("A1:D10", 0, Infinity, -2, 1); // Second last column: "C1:C10"
|
|
151
|
+
*/
|
|
152
|
+
export declare function subaddress(address: Address, skipRows?: number, takeRows?: number, skipCols?: number, takeCols?: number): Address;
|
|
153
|
+
/**
|
|
154
|
+
* Extracts a subrange from a WorkbookRangeRef using skip/take semantics.
|
|
143
155
|
* @param rangeRef Range reference to extract the sub-range from.
|
|
144
|
-
* @param
|
|
145
|
-
* @param
|
|
156
|
+
* @param skipRows Number of rows to skip. If negative, skips from the end. Default 0.
|
|
157
|
+
* @param takeRows Number of rows to take after skipping. If negative, excludes from the end. Default Infinity.
|
|
158
|
+
* @param skipCols Number of columns to skip. If negative, skips from the end. Default 0.
|
|
159
|
+
* @param takeCols Number of columns to take after skipping. If negative, excludes from the end. Default Infinity.
|
|
146
160
|
* @returns Extracted sub-range reference.
|
|
147
161
|
* @throws InvalidArgumentError if the requested rows or columns exceed the available range.
|
|
148
162
|
*/
|
|
149
|
-
export declare function subrange(rangeRef: WorkbookRangeRef,
|
|
163
|
+
export declare function subrange(rangeRef: WorkbookRangeRef, skipRows?: number, takeRows?: number, skipCols?: number, takeCols?: number): WorkbookRangeRef;
|
|
150
164
|
//# sourceMappingURL=addressManipulation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressManipulation.d.ts","sourceRoot":"","sources":["../../../src/services/addressManipulation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAoB,aAAa,EAAsB,UAAU,EAAmB,MAAM,sBAAsB,CAAC;AAGnJ,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAkBtE,MAAM,MAAM,iBAAiB,GAAG;IAC/B,WAAW,EAAE,aAAa,CAAC;IAC3B,SAAS,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,UAAU,CAAC;IACrB,MAAM,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,UAAQ,GAAG,OAAO,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,gB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EAAE,QAAQ,SAA2B,GAAG,OAAO,CAqC1J;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,GAAG,gBAAgB,CAM3K"}
|
|
@@ -254,56 +254,71 @@ export function countAddressColumns(address) {
|
|
|
254
254
|
return columnAddressToOffset(components.endColumn) - columnAddressToOffset(components.startColumn) + 1;
|
|
255
255
|
}
|
|
256
256
|
/**
|
|
257
|
-
* Extracts a
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
257
|
+
* Extracts a subrange from a spreadsheet-style A1 range (e.g., "A1:D10"),
|
|
258
|
+
* allowing skip and take semantics on both rows and columns.
|
|
259
|
+
*
|
|
260
|
+
* Supports negative values for `skipRows` and `skipCols` to count from the end.
|
|
261
|
+
* Supports negative values for `takeRows` and `takeCols` to exclude from the end after skipping.
|
|
262
|
+
*
|
|
263
|
+
* @param address - The original range in A1 notation (e.g., "A1:D10").
|
|
264
|
+
* @param skipRows - Number of rows to skip. If negative, skips that many rows from the end. Default is 0.
|
|
265
|
+
* @param takeRows - Number of rows to take after skipping. If negative, excludes that many rows from the end of the remaining rows. Default is Infinity.
|
|
266
|
+
* @param skipCols - Number of columns to skip. If negative, skips that many columns from the end. Default is 0.
|
|
267
|
+
* @param takeCols - Number of columns to take after skipping. If negative, excludes that many columns from the end of the remaining columns. Default is Infinity.
|
|
268
|
+
* @returns A new A1-style range representing the sliced subrange (e.g., "B2:C5").
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* subaddress("A1:D10", -1, 1); // Last row: "A10:D10"
|
|
272
|
+
* subaddress("A1:D10", -2, 1); // Second last row: "A9:D9"
|
|
273
|
+
* subaddress("A1:D10", 0, -1); // All but last row: "A1:D9"
|
|
274
|
+
* subaddress("A1:D10", 0, Infinity, -2, 1); // Second last column: "C1:C10"
|
|
263
275
|
*/
|
|
264
|
-
export function subaddress(address,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
276
|
+
export function subaddress(address, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
|
|
277
|
+
const { ax, bx, ay, by } = addressToCartesian(address);
|
|
278
|
+
const [startRow, endRow] = slice(ay, by, skipRows, takeRows);
|
|
279
|
+
const [startCol, endCol] = slice(ax, bx, skipCols, takeCols);
|
|
280
|
+
if (startRow < ay || endRow > by || startRow > endRow || startCol < ax || endCol > bx || startCol > endCol) {
|
|
281
|
+
throw new InvalidArgumentError(`Requested subaddress is out of bounds: rows [${startRow + 1},${endRow + 1}], cols [${startCol + 1},${endCol + 1}] in range.`);
|
|
282
|
+
}
|
|
283
|
+
return cartesianToAddress({
|
|
284
|
+
ay: startRow,
|
|
285
|
+
by: endRow,
|
|
286
|
+
ax: startCol,
|
|
287
|
+
bx: endCol,
|
|
288
|
+
});
|
|
289
|
+
function slice(start, end, skip, take) {
|
|
290
|
+
let s = start;
|
|
291
|
+
let e = end;
|
|
292
|
+
if (skip > 0) {
|
|
293
|
+
s = start + skip;
|
|
273
294
|
}
|
|
274
|
-
else if (
|
|
275
|
-
|
|
295
|
+
else if (skip < 0) {
|
|
296
|
+
s = end + skip + 1;
|
|
276
297
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const colCount = bx - ax + 1;
|
|
280
|
-
if (Math.abs(cols) > colCount) {
|
|
281
|
-
throw new InvalidArgumentError(`Requested columns (${cols}) exceed available columns (${colCount}) in range.`);
|
|
298
|
+
if (!Number.isFinite(take)) {
|
|
299
|
+
// do nothing
|
|
282
300
|
}
|
|
283
|
-
if (
|
|
284
|
-
|
|
301
|
+
else if (take >= 0) {
|
|
302
|
+
e = s + take - 1;
|
|
285
303
|
}
|
|
286
|
-
else if (
|
|
287
|
-
|
|
304
|
+
else if (take < 0) {
|
|
305
|
+
e += take;
|
|
288
306
|
}
|
|
307
|
+
return [s, e];
|
|
289
308
|
}
|
|
290
|
-
return cartesianToAddress({
|
|
291
|
-
ay,
|
|
292
|
-
by,
|
|
293
|
-
ax,
|
|
294
|
-
bx,
|
|
295
|
-
});
|
|
296
309
|
}
|
|
297
310
|
/**
|
|
298
|
-
* Extracts a
|
|
311
|
+
* Extracts a subrange from a WorkbookRangeRef using skip/take semantics.
|
|
299
312
|
* @param rangeRef Range reference to extract the sub-range from.
|
|
300
|
-
* @param
|
|
301
|
-
* @param
|
|
313
|
+
* @param skipRows Number of rows to skip. If negative, skips from the end. Default 0.
|
|
314
|
+
* @param takeRows Number of rows to take after skipping. If negative, excludes from the end. Default Infinity.
|
|
315
|
+
* @param skipCols Number of columns to skip. If negative, skips from the end. Default 0.
|
|
316
|
+
* @param takeCols Number of columns to take after skipping. If negative, excludes from the end. Default Infinity.
|
|
302
317
|
* @returns Extracted sub-range reference.
|
|
303
318
|
* @throws InvalidArgumentError if the requested rows or columns exceed the available range.
|
|
304
319
|
*/
|
|
305
|
-
export function subrange(rangeRef,
|
|
306
|
-
const address = subaddress(rangeRef.address,
|
|
320
|
+
export function subrange(rangeRef, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
|
|
321
|
+
const address = subaddress(rangeRef.address, skipRows, takeRows, skipCols, takeCols);
|
|
307
322
|
return {
|
|
308
323
|
...rangeRef,
|
|
309
324
|
address,
|