Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
EventBus.prototype.on = function(events, priority, callback, that) {
events = isArray(events) ? events : [ events ];
if (isFunction(priority)) {
that = callback;
callback = priority;
priority = DEFAULT_PRIORITY;
}
if (!isNumber(priority)) {
throw new Error('priority must be a number');
}
var actualCallback = callback;
if (that) {
actualCallback = bind(callback, that);
// make sure we remember and are able to remove
// bound callbacks via {@link #off} using the original
// callback
actualCallback[FN_REF] = callback[FN_REF] || callback;
}
var self = this;
onGetComponent(type, priority, callback) {
if (isFunction(priority)) {
callback = priority;
priority = DEFAULT_PRIORITY;
}
if (!isNumber(priority)) {
throw new Error('priority must be a number');
}
const listeners = this._getListeners(type);
let existingListener,
idx;
const newListener = { priority, callback };
for (idx = 0; (existingListener = listeners[idx]); idx++) {
if (existingListener.priority < priority) {
// prepend newListener at before existingListener
listeners.splice(idx, 0, newListener);
return;
onGetComponent(type, priority, callback) {
if (isFunction(priority)) {
callback = priority;
priority = DEFAULT_PRIORITY;
}
if (!isNumber(priority)) {
throw new Error('priority must be a number');
}
const listeners = this._getListeners(type);
let existingListener,
idx;
const newListener = { priority, callback };
for (idx = 0; (existingListener = listeners[idx]); idx++) {
if (existingListener.priority < priority) {
// prepend newListener at before existingListener
listeners.splice(idx, 0, newListener);
return;
function insertShape(shape, targetFlow, positionOrBounds) {
var waypoints = targetFlow.waypoints,
waypointsBefore,
waypointsAfter,
dockingPoint,
source,
target,
incomingConnection,
outgoingConnection,
oldOutgoing = shape.outgoing.slice(),
oldIncoming = shape.incoming.slice();
var mid;
if (isNumber(positionOrBounds.width)) {
mid = getMid(positionOrBounds);
} else {
mid = positionOrBounds;
}
var intersection = getApproxIntersection(waypoints, mid);
if (intersection) {
waypointsBefore = waypoints.slice(0, intersection.index);
waypointsAfter = waypoints.slice(intersection.index + (intersection.bendpoint ? 1 : 0));
// due to inaccuracy intersection might have been found
if (!waypointsBefore.length || !waypointsAfter.length) {
return;
}
function getSnapOffset(event, axis, elementRegistry) {
var context = event.context,
shape = event.shape,
gridSnappingContext = context.gridSnappingContext,
snapLocation = gridSnappingContext.snapLocation,
snapOffset = gridSnappingContext.snapOffset;
// cache snap offset
if (snapOffset && isNumber(snapOffset[ axis ])) {
return snapOffset[ axis ];
}
if (!snapOffset) {
snapOffset = gridSnappingContext.snapOffset = {};
}
if (!isNumber(snapOffset[ axis ])) {
snapOffset[ axis ] = 0;
}
if (!shape) {
return snapOffset[ axis ];
}
if (!elementRegistry.get(shape.id)) {
function ensurePx(number) {
return isNumber(number) ? number + 'px' : number;
}
cache[ element.target.id ],
element,
element.parent || parent,
hints
);
return;
}
var createShapeHints = assign({}, hints);
if (parents.indexOf(element) === -1) {
createShapeHints.autoResize = false;
}
cache[ element.id ] = isNumber(parentIndex) ?
modeling.createShape(
element,
pick(element, [ 'x', 'y', 'width', 'height' ]),
element.parent || parent,
parentIndex,
createShapeHints
) :
modeling.createShape(
element,
pick(element, [ 'x', 'y', 'width', 'height' ]),
element.parent || parent,
createShapeHints
);
});
return function _debounceInput(fn) {
if (shouldDebounce !== false) {
var debounceTime =
isNumber(shouldDebounce) ?
shouldDebounce :
DEFAULT_DEBOUNCE_TIME;
return debounce(fn, debounceTime);
} else {
return fn;
}
};
}
forEach(elements, function(element) {
var e = element;
if (e.waypoints) {
e = getBBox(e);
}
if (!isNumber(bbox.y) && (e.x > bbox.x)) {
filteredElements[element.id] = element;
}
if (!isNumber(bbox.x) && (e.y > bbox.y)) {
filteredElements[element.id] = element;
}
if (e.x > bbox.x && e.y > bbox.y) {
if (isNumber(bbox.width) && isNumber(bbox.height) &&
e.width + e.x < bbox.width + bbox.x &&
e.height + e.y < bbox.height + bbox.y) {
filteredElements[element.id] = element;
} else if (!isNumber(bbox.width) || !isNumber(bbox.height)) {
filteredElements[element.id] = element;
}
}
});
update: function(position) {
if (!isNumber(position)) {
svgAttr(line, { display: 'none' });
} else {
if (orientation === 'horizontal') {
svgAttr(line, {
d: 'M-100000,' + position + ' L+100000,' + position,
display: ''
});
} else {
svgAttr(line, {
d: 'M ' + position + ',-100000 L ' + position + ', +100000',
display: ''
});
}
}
}
};