handsontable
Version:
Handsontable is a JavaScript Data Grid available for React, Angular and Vue.
48 lines (44 loc) • 1.15 kB
JavaScript
;
exports.__esModule = true;
exports.getOperationFunc = getOperationFunc;
exports.getOperationName = getOperationName;
exports.registerOperation = registerOperation;
require("core-js/modules/es.error.cause.js");
const operations = exports.operations = {};
/**
* Get operation closure with pre-bound arguments.
*
* @param {string} id Operator `id`.
* @returns {Function}
*/
function getOperationFunc(id) {
if (!operations[id]) {
throw Error(`Operation with id "${id}" does not exist.`);
}
const func = operations[id].func;
return function (conditions, value) {
return func(conditions, value);
};
}
/**
* Return name of operation which is displayed inside UI component, basing on it's `id`.
*
* @param {string} id `Id` of operation.
* @returns {string}
*/
function getOperationName(id) {
return operations[id].name;
}
/**
* Operator registerer.
*
* @param {string} id Operation `id`.
* @param {string} name Operation name which is displayed inside UI component.
* @param {Function} func Operation function.
*/
function registerOperation(id, name, func) {
operations[id] = {
name,
func
};
}