@eclipse-emfcloud/trigger-engine
Version:
Generic model triggers computation engine.
65 lines • 2.65 kB
JavaScript
;
// *****************************************************************************
// Copyright (C) 2023-2024 STMicroelectronics.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: MIT License which is
// available at https://opensource.org/licenses/MIT.
//
// SPDX-License-Identifier: EPL-2.0 OR MIT
// *****************************************************************************
Object.defineProperty(exports, "__esModule", { value: true });
exports.nonTestOperations = nonTestOperations;
exports.addOperations = addOperations;
exports.addOrReplaceOperations = addOrReplaceOperations;
exports.removeOperations = removeOperations;
/**
* Extract the operations from a patch that are not `'test'` operations, for ease of analysis.
*
* @param patch a JSON patch
* @returns the non-`'test'` operations
*/
function nonTestOperations(patch) {
return patch.filter((op) => op.op !== 'test');
}
/**
* Extract the operations from a patch that are `'add'` operations, for ease of analysis.
*
* @param patch a JSON patch
* @param valueGuard an optional type guard on the value of the add and remove patches to select
* @returns the `'add'` operations, optionally matching the type guard on the value
*/
function addOperations(patch, valueGuard) {
if (valueGuard) {
return patch.filter((op) => op.op === 'add' && valueGuard(op.value));
}
return patch.filter((op) => op.op === 'add');
}
/**
* Extract the operations from a patch that are `'add'` or `'replace'` operations, for ease of analysis.
*
* @param patch a JSON patch
* @param valueGuard an optional type guard on the value of the add and remove patches to select
* @returns the `'add'` and `'replace'` operations, optionally matching the type guard on the value
*/
function addOrReplaceOperations(patch, valueGuard) {
if (valueGuard) {
return patch.filter((op) => (op.op === 'add' || op.op === 'replace') && valueGuard(op.value));
}
return patch.filter((op) => op.op === 'add' || op.op === 'replace');
}
/**
* Extract the operations from a patch that are `'remove'` operations, for ease of analysis.
*
* @param patch a JSON patch
* @returns the `'remove'` operations
*/
function removeOperations(patch) {
return patch.filter((op) => op.op === 'remove');
}
//# sourceMappingURL=trigger.js.map