quietflow.js
Paul Krishnamurthy 2016

https://paulkr.com
paul@paulkr.com
348840
function randCol (r, g, b, a) {
  return "rgba(" + Math.floor(Math.random() * r).toString() + "," +
                   Math.floor(Math.random() * g).toString() + "," +
                   Math.floor(Math.random() * b).toString() + "," + a + ")";
}
1007597
async function speechTreeApi(server, options, next) {
  if (!options.speechClassifier) {
    return next(TypeError('speech classifier must be specified'));
  }

  if (typeof options.speechClassifier != 'function') {
    return next(TypeError('speech classifier must be a function'));
  }

  const apiUrl = '/' + settings.apiUrl.split('/').pop();

  server.route({
    method: ['GET'],
    path: `${apiUrl}/label`,
    async handler(request, reply) {
      const sentence = request.query.sentence;

      if (!sentence) {
        const error = boom.badRequest('sentence must be provided');
        return reply(error);
      }

      let label = options.speechClassifier(sentence);

      if (!label) {
        const error = boom.notFound('label not found');
        return reply(error);
      }

      if (typeof label.then == 'function' &&
          typeof label.catch == 'function') {
        label = await label;
      }

      if (typeof label != 'string') {
        throw TypeError('label must be a string');
      }

      reply({ label });
    }
  });

  next();
}
868948
function dflowFun () {
    var gotReturn = false
    var returnValue
    var outs = {}

    // Inject run-time builtin tasks.

    funcs['this'] = function () { return dflowFun }
    funcs['this.graph'] = function () { return graph }
    injectArguments(funcs, task, arguments)

    /**
     * Execute task.
     */

    function run (taskKey) {
      var args = inputArgs(outs, pipe, taskKey)
      var taskName = task[taskKey]
      var f = funcs[taskName]

      // Behave like a JavaScript function:
      // if found a return, skip all other tasks.

      if (gotReturn) return

      if ((taskName === 'return') && (!gotReturn)) {
        returnValue = args[0]
        gotReturn = true
        return
      }

      // If task is not defined at run time, throw an error.

      if (no(f)) {
        var taskNotFound = new Error('Task not found: ' + taskName + ' [' + taskKey + '] ')
        taskNotFound.taskKey = taskKey
        taskNotFound.taskName = taskName
      }

      // Try to execute task.

      try {
        outs[taskKey] = f.apply(null, args)
      } catch (err) {
        // Enrich error with useful dflow task info.
        err.taskName = taskName
        err.taskKey = taskKey

        throw err
      }
    }

    // Run every graph task, sorted by level.

    Object.keys(task)
      .filter(comments)
      .sort(byLevel)
      .forEach(run)

    return returnValue
  }
1190436
function authReducer(state: AuthState = INITIAL_STATE, action = {}) {
  switch (action.type) {
    case t.LOGIN_FAILURE:
    case t.SIGNUP_USER_FAILURE:
    case t.CHECK_AUTH_FAILURE:
      return {
        ...state,
        loading: false,
        isAuthenticated: false,
        token: '',
        error: action.error,
      };
    case t.LOGIN_REQUEST:
    case t.CHECK_AUTH_REQUEST:
    case t.SIGNUP_USER_REQUEST:
      return {
        ...state,
        loading: true,
        isAuthenticated: false,
      };
    case t.LOGIN_SUCCESS:
      return {
        ...state,
        loading: false,
        isAuthenticated: true,
        token: action.token,
        info: action.info,
      };
    case t.CHECK_AUTH_SUCCESS:
      return {
        ...state,
        loading: false,
        isAuthenticated: true,
        token: action.token,
        info: {
          id: action.account.id,
          email: action.account.email,
          firstName: action.account.profile.firstName,
          lastName: action.account.profile.lastName,
          username: action.account.profile.username,
          avatarUrl: action.account.profile.avatarUrl,
          profileImage: action.account.profile.profileImage,
          location: action.account.profile.location,
          bio: action.account.profile.bio,
          website: action.account.profile.website,
          socialMedia: action.account.profile.socialMedia,
          role: action.account.roles[0].name,
          roleId: action.account.roles[0].id,
        },
      };
    case t.LOGOUT:
      return {
        loading: false,
        error: null,
        isAuthenticated: false,
        token: '',
        info: {
          firstName: '',
          lastName: '',
          email: '',
          username: '',
          avatarUrl: '',
          role: '',
          roleId: null,
        },
      };
    case t.SIGNUP_USER_SUCCESS:
      return {
        ...state,
        loading: false,
      };
    default:
      return state;
  }
}
1224275
function unpipe (stream) {
  if (!stream) {
    throw new TypeError('argument stream is required')
  }

  if (typeof stream.unpipe === 'function') {
    // new-style
    stream.unpipe()
    return
  }

  // Node.js 0.8 hack
  if (!hasPipeDataListeners(stream)) {
    return
  }

  var listener
  var listeners = stream.listeners('close')

  for (var i = 0; i < listeners.length; i++) {
    listener = listeners[i]

    if (listener.name !== 'cleanup' && listener.name !== 'onclose') {
      continue
    }

    // invoke the listener
    listener.call(stream)
  }
}
192315
function consoleLog(){
    console.log("byllllogl-" + h_p + "-" + p_p + " --- step_p:" 
    + step_p + " --- lockedPhase_p:" + lockedPhase_p + " --- lockedValue_p:" + lockedValue_p  + " --- waitingProposer:" + waitingProposer
    + " --- assocByzantinePhase:"+ JSON.stringify(assocByzantinePhase));
}
618935
function _deleteResponsiveFlowLayout( oRFLayout ) {

		if (oRFLayout.__myParentContainerId) {
			oRFLayout.__myParentContainerId = undefined;
		}
		if (oRFLayout.__myParentElementId) {
			oRFLayout.__myParentElementId = undefined;
		}
		oRFLayout.__myParentLayout = undefined;

		oRFLayout.destroy();

	}
1255140
function getSubflow(_, ctx) {
  var spec = _.$subflow;
  return function(dataflow, key, parent) {
    var subctx = parseDataflow(spec, ctx.fork()),
        op = subctx.get(spec.operators[0].id),
        p = subctx.signals.parent;
    if (p) p.set(parent);
    return op;
  };
}
55953
function speechTreeApi(options) {
  if (!options.speechClassifier) {
    throw TypeError('speech classifier must be specified');
  }

  if (typeof options.speechClassifier != 'function') {
    throw TypeError('speech classifier must be a function');
  }

  const router = express.Router();
  const apiUrl = '/' + settings.apiUrl.split('/').pop();

  router.get(`${apiUrl}/label`, async (req, res) => {
    const sentence = req.query.sentence;

    if (!sentence) {
      res.status(400);
      return res.send('sentence must be provided');
    }

    let label = options.speechClassifier(sentence);

    if (!label) {
      res.status(404);
      return res.send('label not found');
    }

    if (typeof label.then == 'function' &&
        typeof label.catch == 'function') {
      label = await label;
    }

    if (typeof label != 'string') {
      throw TypeError('label must be a string');
    }

    res.status(200);
    res.setHeader('Content-Type', 'application/json');
    res.send(JSON.stringify({ label }));
  });

  return router;
}
238154
function(event, queue, visited) {
      event.outFlowEvents.forEach(function(outflow) {
        if ((outflow.category === POSTTASK_FLOW_EVENT ||
            outflow.category === IPC_FLOW_EVENT) &&
            outflow.endSlice) {
          this.associatedEvents_.push(outflow);

          var nextEvent = outflow.endSlice.mostTopLevelSlice;
          if (!visited.contains(nextEvent)) {
            visited.push(nextEvent);
            queue.push(nextEvent);
          }
        }
      }, this);
    }
591248
function SandboxPO() {
    // whitelist checkbox inputs
    this.checkboxes = ["link.renderLabel", "node.renderLabel", "staticGraph", "collapsible", "directed"];

    // actions
    this.fullScreenMode = () => cy.get(".container__graph > :nth-child(1) > :nth-child(1)");
    this.playGraph = () => cy.get(".container__graph > :nth-child(1) > :nth-child(2)").click();
    this.pauseGraph = () => cy.get(".container__graph > :nth-child(1) > :nth-child(3)").click();
    this.addNode = () => cy.get(".container__graph > :nth-child(1) > :nth-child(5)").click();
    this.removeNode = () => cy.get(".container__graph > :nth-child(1) > :nth-child(6)").click();
    this.clickJsonTreeNodes = () => {
        cy.get(".container__graph-data")
            .contains("root")
            .scrollIntoView();
        cy.get(".container__graph-data")
            .contains("nodes")
            .click();
    };
    // must be collapsed
    this.clickJsonTreeFirstNode = () =>
        cy
            .get(
                ":nth-child(2) > .rejt-not-collapsed > .rejt-not-collapsed-list > :nth-child(1) > .rejt-collapsed > .rejt-collapsed-text"
            )
            .click();
    this.addJsonTreeFirstNodeProp = () =>
        cy.get(":nth-child(2) > :nth-child(1) > .rejt-not-collapsed > :nth-child(4) > .rejt-plus-menu").click();
    this.deleteJsonTreeFirstNodeProp = () =>
        cy.get(".rejt-not-collapsed-list > :nth-child(2) > .rejt-minus-menu").click();

    // element getters
    this.getFieldInput = field =>
        this.checkboxes.includes(field)
            ? cy.contains(field).children("input")
            : cy.contains(field).siblings(".form-control");
    this.getGraphNumbers = () => cy.get(".container__graph-info");
}
306378
function browserTask(minify) {
  return function() {
    var task = browserify(
        {
          entries: [index],
          standalone: 'Asana'
        })
        .bundle()
        .pipe(vinylSourceStream('asana' + (minify ? '-min' : '') + '.js'));
    if (minify) {
      task = task
          .pipe(vinylBuffer())
          .pipe(uglify());
    }
    return task.pipe(gulp.dest('dist'));
  };
}
1120390
function (v) {
/*Line 29 - 'AtomUploadButton.js' */                this._accept = v;
/*Line 30 - 'AtomUploadButton.js' */                if (v) {
/*Line 31 - 'AtomUploadButton.js' */                    var fp = this._filePresenter;
/*Line 32 - 'AtomUploadButton.js' */                    if (fp) {
/*Line 33 - 'AtomUploadButton.js' */                        AtomUI.attr(fp, "accept", v);
/*Line 34 - 'AtomUploadButton.js' */                    }
/*Line 35 - 'AtomUploadButton.js' */                }
/*Line 36 - 'AtomUploadButton.js' */            }
1274276
function() {
        const flow = this._chooseFlow();
        console.log("Active flow => %s", JSON.stringify(flow));
        const nextStage = this._firstUncompletedStage(flow);
        console.log("Next stage: %s", nextStage);
        return nextStage;
    }
1326605
private void push(double[][] flow, double[] excess, int u, int v) {
        double send = Math.min(excess[u], graph[u][v] - flow[u][v]);
        flow[u][v] += send;
        flow[v][u] -= send;
        excess[u] -= send;
        excess[v] += send;
    }
1043908
function ask(questions, finish, answers, input, output) {
    finish = finish || function() {};
    input = input || function(cb) {process.stdin.on('data', cb);};
    output = output || function(a) {console.log(a);};

    var i = 0;
    var ret = {};
    var e = questions[0];
    var v = match(ops, e);

    output(getOutput(e, v));
    input(getInput);

    function getOutput(e, v) {
        var o = f.isFunction(v.output)? v.output(e): '';

        return e.q + o;
    }

    function getInput(t) {
        t = t.trim();
        var r = v.exec(t, e);

        if(f.isDefined(r)) {
            ret[e.id] = r;
            i++;

            if(i >= questions.length) {
                // XXX: separate this somehow
                process.stdin.removeListener('data', getInput);
                process.stdin.pause();

                finish(ret);
            }
            else {
                e = questions[i];
                v = match(ops, e);
                output(getOutput(e, v));
            }
        }
    }
}
808664
function (txt) {
    
/*Line 10 - 'AtomEvaluator.js' */            // http://jsfiddle.net/A3vg6/44/ (recommended)
/*Line 11 - 'AtomEvaluator.js' */            // http://jsfiddle.net/A3vg6/45/ (working)
/*Line 12 - 'AtomEvaluator.js' */            // http://jsfiddle.net/A3vg6/51/ (including $ sign)
    
/*Line 14 - 'AtomEvaluator.js' */            var be = this.becache[txt];
/*Line 15 - 'AtomEvaluator.js' */            if (be)
/*Line 16 - 'AtomEvaluator.js' */                return be;
    
/*Line 18 - 'AtomEvaluator.js' */            var regex = /(?:(\$)(window|localViewModel|viewModel|appScope|scope|data|owner|localScope))(?:\.[a-zA-Z_][a-zA-Z_0-9]*(\()?)*/gi;
    
/*Line 20 - 'AtomEvaluator.js' */            var keywords = /(window|localViewModel|viewModel|appScope|scope|data|owner|localScope)/gi;
    
/*Line 22 - 'AtomEvaluator.js' */            var path = [];
/*Line 23 - 'AtomEvaluator.js' */            var vars = [];
    
/*Line 25 - 'AtomEvaluator.js' */            var found = {};
    
/*Line 27 - 'AtomEvaluator.js' */            var ms = txt.replace(regex,
/*Line 28 - 'AtomEvaluator.js' */                function (match) {
/*Line 29 - 'AtomEvaluator.js' */                    var nv = "v" + (path.length + 1);
/*Line 30 - 'AtomEvaluator.js' */                    if (match.indexOf("$owner.") == 0) {
/*Line 31 - 'AtomEvaluator.js' */                        match = match.substr(7);
/*Line 32 - 'AtomEvaluator.js' */                    } else
/*Line 33 - 'AtomEvaluator.js' */                    {
/*Line 34 - 'AtomEvaluator.js' */                        if (match.indexOf("owner.") == 0) {
/*Line 35 - 'AtomEvaluator.js' */                            match = match.substr(6);
/*Line 36 - 'AtomEvaluator.js' */                        } else {
/*Line 37 - 'AtomEvaluator.js' */                            match = match.substr(1);
/*Line 38 - 'AtomEvaluator.js' */                        }
/*Line 39 - 'AtomEvaluator.js' */                    }

/*Line 41 - 'AtomEvaluator.js' */                    match = match.split(".");

/*Line 43 - 'AtomEvaluator.js' */                    var trail = "";

/*Line 45 - 'AtomEvaluator.js' */                    match = match.filter(function(m) {
/*Line 46 - 'AtomEvaluator.js' */                        if(!m.endsWith("(")){
/*Line 47 - 'AtomEvaluator.js' */                            return true;
/*Line 48 - 'AtomEvaluator.js' */                        }
/*Line 49 - 'AtomEvaluator.js' */                        trail = "." + m;
/*Line 50 - 'AtomEvaluator.js' */                        return false;
/*Line 51 - 'AtomEvaluator.js' */                    });

/*Line 53 - 'AtomEvaluator.js' */                    path.push(match);
/*Line 54 - 'AtomEvaluator.js' */                    vars.push(nv);
/*Line 55 - 'AtomEvaluator.js' */                    return "(" + nv + ")" + trail;
/*Line 56 - 'AtomEvaluator.js' */                }
/*Line 57 - 'AtomEvaluator.js' */                );
    
    
/*Line 60 - 'AtomEvaluator.js' */            var method = "return " + ms + ";";
/*Line 61 - 'AtomEvaluator.js' */            var methodString = method;
/*Line 62 - 'AtomEvaluator.js' */            try {
/*Line 63 - 'AtomEvaluator.js' */                method = AtomEvaluator.compile(vars, method);
/*Line 64 - 'AtomEvaluator.js' */            } catch (e) {
/*Line 65 - 'AtomEvaluator.js' */                throw new Error("Error executing \n" + methodString + "\nOriginal: " + txt + "\r\n" + e);
/*Line 66 - 'AtomEvaluator.js' */            }
    
/*Line 68 - 'AtomEvaluator.js' */            be = { length: vars.length, method: method, path: path, original: ms };
/*Line 69 - 'AtomEvaluator.js' */            this.becache[txt] = be;
/*Line 70 - 'AtomEvaluator.js' */            return be;
/*Line 71 - 'AtomEvaluator.js' */        }