@joshfarrant/shortcuts-js
Version:
An iOS 12 Shortcuts creator
46 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../utils");
/** @ignore */
const operationsMap = new Map([
['*', '×'],
['x', '×'],
['/', '÷'],
['sqrt', '√x'],
['cbrt', '∛x'],
]);
/**
* @action Calculate
* @section Actions > Scripting > Maths
* @icon Calculator
*
* Performs a number operation on the input and returns the result.
*
* ```js
* // Divide the input by 7
* calculate({
* operand: 7,
* operation: '/',
* });
* ```
*/
const calculate = ({ operand, operation = '+', scientificOperation, }) => {
let parameters;
if (scientificOperation) {
const WFScientificMathOperation = operationsMap.get(scientificOperation) || scientificOperation;
parameters = Object.assign(Object.assign({ WFMathOperation: '…' }, (operand !== undefined && { WFScientificMathOperand: operand })), { WFScientificMathOperation: WFScientificMathOperation });
}
else {
const WFMathOperation = (operationsMap.get(operation) || operation);
parameters = {
WFMathOperand: operand || 42,
WFMathOperation: WFMathOperation,
};
}
return {
WFWorkflowActionIdentifier: 'is.workflow.actions.math',
WFWorkflowActionParameters: parameters,
};
};
exports.default = utils_1.withActionOutput(calculate);
//# sourceMappingURL=calculate.js.map