mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 11:25:09 +00:00
Spreadsheet: Allow integer() to throw in weird cases
Also makes numericResolve use parseInt to avoid using our own integer()
This commit is contained in:
parent
75a02300ba
commit
4147b56e79
2 changed files with 37 additions and 1 deletions
|
@ -365,6 +365,9 @@ function randRange(min, max) {
|
|||
}
|
||||
|
||||
function integer(value) {
|
||||
const typeVal = typeof value;
|
||||
if ((typeVal !== "number" && typeVal !== "string") || Number.isNaN(Number(value)))
|
||||
throw new Error(`integer() called with unexpected type "${typeVal}"`);
|
||||
return value | 0;
|
||||
}
|
||||
|
||||
|
@ -381,7 +384,7 @@ function numericReduce(op, accumulator, cells) {
|
|||
}
|
||||
|
||||
function numericResolve(cells) {
|
||||
return resolve(cells).map(str => (str === "" || str == null ? NaN : integer(str)));
|
||||
return resolve(cells).map(val => parseInt(val));
|
||||
}
|
||||
|
||||
function resolve(cells) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue