/* TODO:  make private
184324
Tuple<String, DistributedUserLayout> getUserLayoutTuple(
            String userName, int userId) {

        final PersonImpl person = new PersonImpl();
        person.setUserName(userName);
        person.setID(userId);
        person.setSecurityContext(new BrokenSecurityContext());

        final IUserProfile profile =
                layoutStore.getUserProfileByFname(person, UserProfile.DEFAULT_PROFILE_FNAME);
        final DistributedUserLayout userLayout =
                layoutStore.getUserLayout(person, (UserProfile) profile);

        return new Tuple<String, DistributedUserLayout>(userName, userLayout);
    }
174207
function makeQueryString(obj, prefix='') {
	const str = [];
	let prop;
	let key;
	let value;

	for (prop in obj) {
		if (obj.hasOwnProperty(prop)) {
			key = prefix ?
				prefix + '[' + prop + ']' :
				prop;
			value = obj[prop];
			str.push(typeof value === 'object' ?
				makeQueryString(value, key) :
				encodeURIComponent(key) + '=' + encodeURIComponent(value));
		}
	}

	return str.join('&');
}
844977
function (obj, key) {
    var tokens = key.replace(/\{|\}/g, '').split(".") || [],
      currVal = obj || {};
    for (var ix = 0, len = tokens.length; ix < len; ix++) {
      if ((typeof currVal === 'undefined') || (currVal === null)) {
        break;
      }
      var currentToken = tokens[ix];
      currVal = currVal[currentToken];
    }
    return currVal;
  }
1280089
function (mode, code, tokens, flags, scope, parseMode) {
    var index = code.index,
        length = code.length;

    if ( /* <!-- */
        code.codePointAt(index) === 0x003c &&
        code.codePointAt(++index) === 0x0021 &&
        code.codePointAt(++index) === 0x002d &&
        code.codePointAt(++index) === 0x002d
    ) {
        index++;

        for (; index < length; index++) {
            if ( /* --> */
                code.codePointAt(index) === 0x002d &&
                code.codePointAt(index + 1) === 0x002d &&
                code.codePointAt(index + 2) === 0x003e
            ) {
                index += 3;
                code.index = index;

                return true;
            }
        }

        throw code.makeError(
            code.index, code.index + 4,
            'Unclosed Comment: Expected "-->" to fallow "<!--".'
        );
    }

    return null;
}
1285239
function templateNodeTransformation( $functionName, &$node,
                                         $tpl, &$parameters, $privateData )
    {
        // {while <condition> [sequence <sequence_array> as $<sequence_var>]}

        $tpl->WhileCounter++;
        $newNodes      = array();
        $nodePlacement = eZTemplateNodeTool::extractFunctionNodePlacement( $node );
        $uniqid        =  md5( $nodePlacement[2] ) . "_" . $tpl->WhileCounter;

        $loop = new eZTemplateCompiledLoop( eZTemplateWhileFunction::FUNCTION_NAME,
                                            $newNodes, $parameters, $nodePlacement, $uniqid,
                                            $node, $tpl, $privateData );


        $loop->initVars();

        // loop header
        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "while ( 1 ) // while\n{" );
        $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
        $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $parameters['condition'], $nodePlacement, array( 'treat-value-as-non-object' => true ),
                                                              "while_cond" );
        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if ( ! \$while_cond ) break;\n" );

        $loop->processBody();

        // loop footer
        $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "} // end of while\n" );
        $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode( 'while_cond' );
        $loop->cleanup();

        return $newNodes;
    }
430769
function makeRelPath(inSource, inTarget) {
	// node 0.5 has this nice thing, 0.4 does not
	if (path.relative) {
		return path.relative(inSource, inTarget);
	}
	var s,t;
	s = pathSplit(path.resolve(inSource));
	t = pathSplit(path.resolve(inTarget));
	while (s.length && s[0] === t[0]){
		s.shift();
		t.shift();
	}
	for(var i = 0, l = s.length; i < l; i++) {
		t.unshift("..");
	}
	return path.join.apply(null, t);
}
768867
@SuppressWarnings("unchecked")
	protected T init(String algorithm, PrivateKey privateKey, PublicKey publicKey) {
		this.algorithm = algorithm;

		if (null == privateKey && null == publicKey) {
			initKeys();
		} else {
			if (null != privateKey) {
				this.privateKey = privateKey;
			}
			if (null != publicKey) {
				this.publicKey = publicKey;
			}
		}
		return (T) this;
	}
406723
function(list, prefix, postfix) {
            prefix  = prefix  ? prefix.value  : "[";
            postfix = postfix ? postfix.value : "]";
            return new Anonymous(toString(list, prefix, postfix));
        }
555860
function modifyState($n) {
    var state = self.state;

    function selectByStateRecursive(name) {
      if (state.recursive) {
        return $n.find(name);
      } else {
        return $n.children(name)
      }
    }

    var a;
    var b;
    if (state.mode == 'code') {
      a = selectByStateRecursive('pre:visible');
      if (a.length > 0)
//        a.hide();
        hideShowCode(a, 'hide');
      else {
        a = selectByStateRecursive('pre');
//        a.show();
        hideShowCode(a, 'show');
      }
    }
    if (state.mode == 'childs') {
      a = selectByStateRecursive('.node:visible');
      if (a.length > 0)
        hideShowNodes(a, 'hide');
//        a.hide();
      else {
        a = selectByStateRecursive('.node');
//        a.show();
        hideShowNodes(a, 'show');
      }
    }
    if (state.mode == 'code childs') {
      a = selectByStateRecursive('.node:hidden');
      b = selectByStateRecursive('pre:hidden');

      if (a.length > 0 || b.length > 0) {
        hideShowNodes(a, 'show');
        hideShowCode(b, 'show');
//        a.show();
//        b.show();
      } else {
        a = selectByStateRecursive('.node');
        b = selectByStateRecursive('pre');
        hideShowNodes(a, 'hide');
        hideShowCode(b, 'hide');
//        a.hide();
//        b.hide();
      }
    }
  }
527786
function _groupWith (makeValue) {
    return function (arrayLike, iteratee) {
        var result = {};
        var len = arrayLike.length;

        for (var i = 0, element, key; i < len; i++) {
            element = arrayLike[i];
            key = iteratee(element, i, arrayLike);
            result[key] = makeValue(result[key], element);
        }

        return result;
    };
}
1063186
function (mode, code, tokens, flags, scope, parseMode) {
    var index = code.index + 2,
        length = code.length;

    if ( /* ! */
        code.codePointAt(index) === 0x0021
    ) {
        if (
            code.codePointAt(++index) === 0x002d &&
            code.codePointAt(++index) === 0x002d
        ) {
            index++;

            for (; index < length; index++) {
                if ( /* --}} */
                    code.codePointAt(index) === 0x002d &&
                    code.codePointAt(index + 1) === 0x002d &&
                    code.codePointAt(index + 2) === 0x007d &&
                    code.codePointAt(index + 3) === 0x007d
                ) {
                    index += 4; /* for --}} */
                    code.index = index;

                    parseMode.close();

                    if (flags.keepComments) {
                        // make a CommentToken and return that.
                    }

                    return true;
                }
            }

            throw code.makeError(
                'Unclosed Comment: Expected "--}}" to fallow "{{!--".',
                5
            );
        }

        index++;

        for (; index < length; index++) {

            if ( /* }} */
                code.codePointAt(index) === 0x007d &&
                code.codePointAt(index + 1) === 0x007d
            ) {
                index += 2; /* for }} */
                code.index = index;

                parseMode.close();

                if (flags.keepComments) {
                    // make a CommentToken and return that.
                }

                return true;
            }
        }

        throw code.makeError(
            code.index, code.index + 3,
            'Unclosed Comment: Expected "}}" to fallow "{{!".'
        );
    }

    return null;
}
998414
private Op compile(Token tok, Op next, boolean reverse) {
		Op ret;
		switch (tok.type) {
		case Token.DOT:
			ret = Op.createDot();
			ret.next = next;
			break;

		case Token.CHAR:
			ret = Op.createChar(tok.getChar());
			ret.next = next;
			break;

		case Token.ANCHOR:
			ret = Op.createAnchor(tok.getChar());
			ret.next = next;
			break;

		case Token.RANGE:
		case Token.NRANGE:
			ret = Op.createRange(tok);
			ret.next = next;
			break;

		case Token.CONCAT:
			ret = next;
			if (!reverse) {
				for (int i = tok.size() - 1; i >= 0; i--) {
					ret = compile(tok.getChild(i), ret, false);
				}
			} else {
				for (int i = 0; i < tok.size(); i++) {
					ret = compile(tok.getChild(i), ret, true);
				}
			}
			break;

		case Token.UNION:
			Op.UnionOp uni = Op.createUnion(tok.size());
			for (int i = 0; i < tok.size(); i++) {
				uni.addElement(compile(tok.getChild(i), next, reverse));
			}
			ret = uni; // ret.next is null.
			break;

		case Token.CLOSURE:
		case Token.NONGREEDYCLOSURE:
			Token child = tok.getChild(0);
			int min = tok.getMin();
			int max = tok.getMax();
			if (min >= 0 && min == max) { // {n}
				ret = next;
				for (int i = 0; i < min; i++) {
					ret = compile(child, ret, reverse);
				}
				break;
			}
			if (min > 0 && max > 0)
				max -= min;
			if (max > 0) {
				// X{2,6} -> XX(X(X(XX?)?)?)?
				ret = next;
				for (int i = 0; i < max; i++) {
					Op.ChildOp q = Op
							.createQuestion(tok.type == Token.NONGREEDYCLOSURE);
					q.next = next;
					q.setChild(compile(child, ret, reverse));
					ret = q;
				}
			} else {
				Op.ChildOp op;
				if (tok.type == Token.NONGREEDYCLOSURE) {
					op = Op.createNonGreedyClosure();
				} else { // Token.CLOSURE
					op = Op.createClosure(this.numberOfClosures++);
				}
				op.next = next;
				op.setChild(compile(child, op, reverse));
				ret = op;
			}
			if (min > 0) {
				for (int i = 0; i < min; i++) {
					ret = compile(child, ret, reverse);
				}
			}
			break;

		case Token.EMPTY:
			ret = next;
			break;

		case Token.STRING:
			ret = Op.createString(tok.getString());
			ret.next = next;
			break;

		case Token.BACKREFERENCE:
			ret = Op.createBackReference(tok.getReferenceNumber());
			ret.next = next;
			break;

		case Token.PAREN:
			if (tok.getParenNumber() == 0) {
				ret = compile(tok.getChild(0), next, reverse);
			} else if (reverse) {
				next = Op.createCapture(tok.getParenNumber(), next);
				next = compile(tok.getChild(0), next, reverse);
				ret = Op.createCapture(-tok.getParenNumber(), next);
			} else {
				next = Op.createCapture(-tok.getParenNumber(), next);
				next = compile(tok.getChild(0), next, reverse);
				ret = Op.createCapture(tok.getParenNumber(), next);
			}
			break;

		case Token.LOOKAHEAD:
			ret = Op.createLook(Op.LOOKAHEAD, next,
					compile(tok.getChild(0), null, false));
			break;
		case Token.NEGATIVELOOKAHEAD:
			ret = Op.createLook(Op.NEGATIVELOOKAHEAD, next,
					compile(tok.getChild(0), null, false));
			break;
		case Token.LOOKBEHIND:
			ret = Op.createLook(Op.LOOKBEHIND, next,
					compile(tok.getChild(0), null, true));
			break;
		case Token.NEGATIVELOOKBEHIND:
			ret = Op.createLook(Op.NEGATIVELOOKBEHIND, next,
					compile(tok.getChild(0), null, true));
			break;

		case Token.INDEPENDENT:
			ret = Op.createIndependent(next,
					compile(tok.getChild(0), null, reverse));
			break;

		case Token.MODIFIERGROUP:
			ret = Op.createModifier(next,
					compile(tok.getChild(0), null, reverse),
					((Token.ModifierToken) tok).getOptions(),
					((Token.ModifierToken) tok).getOptionsMask());
			break;

		case Token.CONDITION:
			Token.ConditionToken ctok = (Token.ConditionToken) tok;
			int ref = ctok.refNumber;
			Op condition = ctok.condition == null ? null : compile(
					ctok.condition, null, reverse);
			Op yes = compile(ctok.yes, next, reverse);
			Op no = ctok.no == null ? null : compile(ctok.no, next, reverse);
			ret = Op.createCondition(next, ref, condition, yes, no);
			break;

		default:
			throw new RuntimeException("Unknown token type: " + tok.type);
		} // switch (tok.type)
		return ret;
	}
1193820
function optimizePropertyAccess(node) {
  var ok =
    node.type === "MemberExpression" &&
    node.computed &&
    node.property.type === "Literal" &&
    typeof node.property.value === "string" &&
    isSafe(node.property.value);
  if (ok) {
    var id = es.Identifier(null, node.property.value);
    return es.MemberExpression(null, false, node.object, id);
  }
}
820650
function makeKeyIndexAndFree (list, key) {
  var keyIndex = {}
  var free = []
  for (var i = 0, len = list.length; i < len; i++) {
    var item = list[i]
    var itemKey = getItemKey(item, key)
    if (itemKey) {
      keyIndex[itemKey] = i
    } else {
      free.push(item)
    }
  }
  return {
    keyIndex: keyIndex,
    free: free
  }
}
1022157
function fromStackProperty(stackString) {
  let chrome = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
  let gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|http|https).*?):(\d+)(?::(\d+))?\s*$/i;
  let lines = stackString.split('\n');
  let stack = [];
  let parts;

  for (let i = 0, j = lines.length; i < j; ++i) {
    if ((parts = gecko.exec(lines[i]))) {
      stack.push({
        url: parts[3],
        func: parts[1] || UNKNOWN_FUNCTION,
        args: parts[2] ? parts[2].split(',') : '',
        line: +parts[4],
        column: parts[5] ? +parts[5] : null
      });
    } else if ((parts = chrome.exec(lines[i]))) {
      stack.push({
        url: parts[2],
        func: parts[1] || UNKNOWN_FUNCTION,
        line: +parts[3],
        column: parts[4] ? +parts[4] : null
      });
    }
  }

  return stack.length ? stack : null;
}
629371
function _makeFileMostRecent(paneId, file) {
        var index,
            entry,
            pane = _getPane(paneId);

        if (!_traversingFileList) {
            pane.makeViewMostRecent(file);

            index = _findFileInMRUList(pane.id, file);

            entry = _makeMRUListEntry(file, pane.id);

            if (index !== -1) {
                _mruList.splice(index, 1);
            }

            if (_findFileInMRUList(pane.id, file) !== -1) {
                console.log(file.fullPath + " duplicated in mru list");
            }

            // add it to the front of the list
            _mruList.unshift(entry);
        }
    }
538560
function (o) {
        var r = [];
        for (var i in o) {
          if (o.hasOwnProperty(i)) {
            r.push(i);
          }
        }
        return r;
      }