How to use the min-dash.reduce function in min-dash

To help you get started, we’ve selected a few min-dash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpmn-io / bpmn-js / lib / features / auto-place / AutoPlaceUtil.js View on Github external
distanceTo: function(shape) {
          var shapeTrbl = asTRBL(shape);

          return sourceTrbl.left - shapeTrbl.right;
        }
      };
    };
  }

  // we create a list of nodes to take into consideration
  // for calculating the optimal flow node distance
  //
  //   * weight existing target nodes higher than source nodes
  //   * only take into account individual nodes once
  //
  var nodes = reduce([].concat(
    getTargets(source, isReference).map(toTargetNode(5)),
    getSources(source, isReference).map(toSourceNode(1))
  ), function(nodes, node) {

    // filter out shapes connected twice via source or target
    nodes[node.shape.id + '__weight_' + node.weight] = node;

    return nodes;
  }, {});

  // compute distances between source and incoming nodes;
  // group at the same time by distance and expose the
  // favourite distance as { fav: { count, value } }.
  var distancesGrouped = reduce(nodes, function(result, node) {

    var shape = node.shape,
github WPS / domain-story-modeler / app / domain-story-modeler / language / DomainStoryRules.js View on Github external
this.addRule('elements.move', HIGH_PRIORITY, function(context) {

    let target = context.target,
        shapes = context.shapes;

    let type;

    // do not allow mixed movements of custom / BPMN shapes
    // if any shape cannot be moved, the group cannot be moved, too
    let allowed = reduce(shapes, function(result, s) {
      if (type === undefined) {
        type = isDomainStory(s);
      }

      if (type !== isDomainStory(s) || result === false) {
        return false;
      }

      return canCreate(s, target);
    }, undefined);

    // reject, if we have at least one
    // custom element that cannot be moved
    return allowed;
  });
github bpmn-io / dmn-js / packages / dmn-js-shared / src / features / modeling / cmd / UpdatePropertiesHandler.js View on Github external
updateProperties(bo, newProps) {

    const ids = this._moddle.ids;

    // Reduce over all new properties and return
    //
    // {
    //  changed,
    //  oldProperties
    // }
    return reduce(newProps, (result, value, key) => {

      const propertyValue = bo.get(key);

      // handle nested update
      if (isContainer(value)) {

        if (!isContainer(propertyValue)) {
          throw new Error(
            `non-existing property <${key}>: cannot update values`
          );
        }

        let {
          changed,
          oldProperties
        } = this.updateProperties(propertyValue, value);
github bpmn-io / diagram-js / lib / core / GraphicsFactory.js View on Github external
GraphicsFactory.prototype.updateContainments = function(elements) {

  var self = this,
      elementRegistry = this._elementRegistry,
      parents;

  parents = reduce(elements, function(map, e) {

    if (e.parent) {
      map[e.parent.id] = e.parent;
    }

    return map;
  }, {});

  // update all parents of changed and reorganized their children
  // in the correct order (as indicated in our model)
  forEach(parents, function(parent) {

    var children = parent.children;

    if (!children) {
      return;
github bpmn-io / bpmn-js / lib / features / modeling / cmd / UpdatePropertiesHandler.js View on Github external
function getProperties(businessObject, properties) {
  var propertyNames = keys(properties);

  return reduce(propertyNames, function(result, key) {

    // handle DI separately
    if (key !== DI) {
      result[key] = businessObject.get(key);
    } else {
      result[key] = getDiProperties(businessObject.di, keys(properties.di));
    }

    return result;
  }, {});
}
github zeebe-io / zeebe-modeler / client / src / app / App.js View on Github external
setDirty(tab, dirty = true) {
    const { tabs } = this.state;

    const newDirtyTabs = reduce(tabs, (dirtyTabs, t) => {
      if (t === tab) {
        return dirtyTabs;
      }

      return {
        ...dirtyTabs,
        [ t.id ]: this.isDirty(t)
      };
    }, {
      [ tab.id ]: dirty
    });

    return {
      dirtyTabs: newDirtyTabs
    };
  }
github bpmn-io / cmmn-js / lib / features / modeling / cmd / UpdatePropertiesHandler.js View on Github external
function getProperties(businessObject, propertyNames) {
  return reduce(propertyNames, function(result, key) {
    result[key] = businessObject.get(key);
    return result;
  }, {});
}
github bpmn-io / dmn-js / packages / dmn-js-decision-table / src / features / copy-cut-paste / DescriptorUtil.js View on Github external
function evaluateReviveHooks(entry, element, hooks, reviveCache) {

  function revive(entry, reviveCache) {
    return reviveDescriptor(entry, reviveCache, hooks);
  }

  return reduce(hooks, function(result, hook) {
    return hook(
      entry,
      result.root,
      result.reviveCache,
      revive
    );
  }, {
    root: element,
    reviveCache: reviveCache
  });
}
github bpmn-io / bpmn-js / lib / features / modeling / cmd / UpdatePropertiesHandler.js View on Github external
function getDiProperties(di, propertyNames) {
  return reduce(propertyNames, function(result, key) {
    result[key] = di.get(key);

    return result;
  }, {});
}