@sudoo/marked
Version:
JavaScript & TypeScript code runner in JavaScript, safe with marked territory, asynchronous
24 lines (23 loc) • 736 B
JavaScript
;
/**
* @author WMXPY
* @namespace Operation
* @description Update
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUpdateOperation = void 0;
const error_code_1 = require("../declare/error-code");
const error_1 = require("../util/error/error");
const getUpdateOperation = (symbol) => {
switch (symbol) {
case "++": return (value) => {
if (typeof value === "number") {
return value + 1;
}
throw (0, error_1.error)(error_code_1.ERROR_CODE.POSITIVE_UPDATE_ONLY_AVAILABLE_FOR_VALID_NUMBER, value);
};
case "--": return (value) => value - 1;
}
return null;
};
exports.getUpdateOperation = getUpdateOperation;