You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.0 KiB
55 lines
1.0 KiB
import { |
|
some |
|
} from 'min-dash'; |
|
|
|
|
|
/** |
|
* Is an element of the given BPMN type? |
|
* |
|
* @param {djs.model.Base|ModdleElement} element |
|
* @param {string} type |
|
* |
|
* @return {boolean} |
|
*/ |
|
export function is(element, type) { |
|
var bo = getBusinessObject(element); |
|
|
|
return bo && (typeof bo.$instanceOf === 'function') && bo.$instanceOf(type); |
|
} |
|
|
|
|
|
/** |
|
* Return true if element has any of the given types. |
|
* |
|
* @param {djs.model.Base} element |
|
* @param {Array<string>} types |
|
* |
|
* @return {boolean} |
|
*/ |
|
export function isAny(element, types) { |
|
return some(types, function(t) { |
|
return is(element, t); |
|
}); |
|
} |
|
|
|
/** |
|
* Return the business object for a given element. |
|
* |
|
* @param {djs.model.Base|ModdleElement} element |
|
* |
|
* @return {ModdleElement} |
|
*/ |
|
export function getBusinessObject(element) { |
|
return (element && element.businessObject) || element; |
|
} |
|
|
|
/** |
|
* Return the di object for a given element. |
|
* |
|
* @param {djs.model.Base} element |
|
* |
|
* @return {ModdleElement} |
|
*/ |
|
export function getDi(element) { |
|
return element && element.di; |
|
} |