hyperformula
Version:
HyperFormula is a JavaScript engine for efficient processing of spreadsheet-like data and formulas
27 lines • 731 B
JavaScript
/**
* @license
* Copyright (c) 2025 Handsoncode. All rights reserved.
*/
import { CellError, ErrorType } from "../../Cell.mjs";
import { FunctionArgumentType, FunctionPlugin } from "./FunctionPlugin.mjs";
export class ModuloPlugin extends FunctionPlugin {
mod(ast, state) {
return this.runFunction(ast.args, state, this.metadata('MOD'), (dividend, divisor) => {
if (divisor === 0) {
return new CellError(ErrorType.DIV_BY_ZERO);
} else {
return dividend % divisor;
}
});
}
}
ModuloPlugin.implementedFunctions = {
'MOD': {
method: 'mod',
parameters: [{
argumentType: FunctionArgumentType.NUMBER
}, {
argumentType: FunctionArgumentType.NUMBER
}]
}
};