Merge pull request #509 from Hongarc/simple

Use simple method of Nodejs instead of `underscore`
This commit is contained in:
Peter Cottle 2018-12-01 10:22:07 -08:00 committed by GitHub
commit 30458e8dbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 243 additions and 261 deletions

View file

@ -62,7 +62,7 @@ module.exports = function(grunt) {
hashedMinFile = 'bundle.js';
}
var jsRegex = /bundle\.min\.\w+\.js/;
_.each(buildFiles, function(jsFile) {
buildFiles.forEach(function(jsFile) {
if (jsRegex.test(jsFile)) {
if (hashedMinFile) {
throw new Error('more than one hashed file: ' + jsFile + hashedMinFile);
@ -76,7 +76,7 @@ module.exports = function(grunt) {
var styleRegex = /main\.\w+\.css/;
var hashedStyleFile;
_.each(buildFiles, function(styleFile) {
buildFiles.forEach(function(styleFile) {
if (styleRegex.test(styleFile)) {
if (hashedStyleFile) {
throw new Error('more than one hashed style: ' + styleFile + hashedStyleFile);
@ -253,4 +253,3 @@ module.exports = function(grunt) {
grunt.registerTask('test', ['jasmine_node']);
grunt.registerTask('casperTest', ['shell:casperTest']);
};

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var intl = require('../intl');
var Errors = require('../util/errors');
@ -34,7 +33,7 @@ var commands = {
if (result.multiDelegate) {
// we need to do multiple delegations with
// a different command at each step
_.each(result.multiDelegate, function(delConfig) {
result.multiDelegate.forEach(function(delConfig) {
// copy command, and then set opts
commandObj.setOptionsMap(delConfig.options || {});
commandObj.setGeneralArgs(delConfig.args || []);
@ -70,7 +69,7 @@ var commands = {
var displayName = config.displayName || name;
var thisMap = {};
// start all options off as disabled
_.each(config.options, function(option) {
(config.options || []).forEach(function(option) {
thisMap[option] = false;
});
optionMap[vcs][displayName] = thisMap;
@ -102,8 +101,10 @@ var commands = {
},
loop: function(callback, context) {
_.each(commandConfigs, function(commandConfig, vcs) {
_.each(commandConfig, function(config, name) {
Object.keys(commandConfigs).forEach(function(vcs) {
var commandConfig = commandConfigs[vcs];
Object.keys(commandConfig).forEach(function(name) {
var config = commandConfig[name];
callback(config, name, vcs);
});
});
@ -116,8 +117,11 @@ var parse = function(str) {
var options;
// see if we support this particular command
_.each(commands.getRegexMap(), function (map, thisVCS) {
_.each(map, function(regex, thisMethod) {
var regexMap = commands.getRegexMap();
Object.keys(regexMap).forEach(function (thisVCS) {
var map = regexMap[thisVCS];
Object.keys(map).forEach(function(thisMethod) {
var regex = map[thisMethod];
if (regex.exec(str)) {
vcs = thisVCS;
method = thisMethod;

View file

@ -1,4 +1,4 @@
var _ = require('underscore');
var escapeString = require('../util/escapeString');
var intl = require('../intl');
var Graph = require('../graph');
@ -190,7 +190,7 @@ var commandConfig = {
var set = Graph.getUpstreamSet(engine, 'HEAD');
// first resolve all the refs (as an error check)
var toCherrypick = _.map(generalArgs, function(arg) {
var toCherrypick = generalArgs.map(function (arg) {
var commit = engine.getCommitFromRef(arg);
// and check that its not upstream
if (set[commit.get('id')]) {
@ -431,7 +431,7 @@ var commandConfig = {
names = names.concat(generalArgs);
command.validateArgBounds(names, 1, Number.MAX_VALUE, '-d');
_.each(names, function(name) {
names.forEach(function(name) {
engine.validateAndDeleteBranch(name);
});
return;
@ -830,7 +830,7 @@ var instantCommands = [
intl.str('git-version'),
'<br/>',
intl.str('git-usage'),
_.escape(intl.str('git-usage-command')),
escapeString(intl.str('git-usage-command')),
'<br/>',
intl.str('git-supported-commands'),
'<br/>'
@ -838,9 +838,10 @@ var instantCommands = [
var commands = require('../commands').commands.getOptionMap()['git'];
// build up a nice display of what we support
_.each(commands, function(commandOptions, command) {
Object.keys(commands).forEach(function(command) {
var commandOptions = commands[command];
lines.push('git ' + command);
_.each(commandOptions, function(vals, optionName) {
Object.keys(commandOptions).forEach(function(optionName) {
lines.push('\t ' + optionName);
}, this);
}, this);
@ -856,4 +857,3 @@ var instantCommands = [
exports.commandConfig = commandConfig;
exports.instantCommands = instantCommands;

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone');
var Q = require('q');
@ -170,7 +169,7 @@ GitEngine.prototype.exportTreeForBranch = function(branchName) {
// now loop through and delete commits
var commitsToLoop = tree.commits;
tree.commits = {};
_.each(commitsToLoop, function(commit, id) {
commitsToLoop.forEach(function(commit, id) {
if (set[id]) {
// if included in target branch
tree.commits[id] = commit;
@ -179,7 +178,7 @@ GitEngine.prototype.exportTreeForBranch = function(branchName) {
var branchesToLoop = tree.branches;
tree.branches = {};
_.each(branchesToLoop, function(branch, id) {
branchesToLoop.forEach(function(branch, id) {
if (id === branchName) {
tree.branches[id] = branch;
}
@ -200,30 +199,28 @@ GitEngine.prototype.exportTree = function() {
HEAD: null
};
_.each(this.branchCollection.toJSON(), function(branch) {
this.branchCollection.toJSON().forEach(function(branch) {
branch.target = branch.target.get('id');
delete branch.visBranch;
totalExport.branches[branch.id] = branch;
});
_.each(this.commitCollection.toJSON(), function(commit) {
this.commitCollection.toJSON().forEach(function(commit) {
// clear out the fields that reference objects and create circular structure
_.each(Commit.prototype.constants.circularFields, function(field) {
Commit.prototype.constants.circularFields.forEach(function(field) {
delete commit[field];
}, this);
});
// convert parents
var parents = [];
_.each(commit.parents, function(par) {
parents.push(par.get('id'));
commit.parents = (commit.parents || []).map(function(par) {
return par.get('id');
});
commit.parents = parents;
totalExport.commits[commit.id] = commit;
}, this);
_.each(this.tagCollection.toJSON(), function(tag) {
this.tagCollection.toJSON().forEach(function(tag) {
delete tag.visTag;
tag.target = tag.target.get('id');
@ -282,18 +279,18 @@ GitEngine.prototype.instantiateFromTree = function(tree) {
// now we do the loading part
var createdSoFar = {};
_.each(tree.commits, function(commitJSON) {
Object.values(tree.commits).forEach(function(commitJSON) {
var commit = this.getOrMakeRecursive(tree, createdSoFar, commitJSON.id, this.gitVisuals);
this.commitCollection.add(commit);
}, this);
_.each(tree.branches, function(branchJSON) {
Object.values(tree.branches).forEach(function(branchJSON) {
var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id, this.gitVisuals);
this.branchCollection.add(branch, {silent: true});
}, this);
_.each(tree.tags, function(tagJSON) {
Object.values(tree.tags || {}).forEach(function(tagJSON) {
var tag = this.getOrMakeRecursive(tree, createdSoFar, tagJSON.id, this.gitVisuals);
this.tagCollection.add(tag, {silent: true});
@ -362,7 +359,8 @@ GitEngine.prototype.makeOrigin = function(treeString) {
var originTree = JSON.parse(unescape(treeString));
// make an origin branch for each branch mentioned in the tree if its
// not made already...
_.each(originTree.branches, function(branchJSON, branchName) {
Object.keys(originTree.branches).forEach(function(branchName) {
var branchJSON = originTree.branches[branchName];
if (this.refs[ORIGIN_PREFIX + branchName]) {
// we already have this branch
return;
@ -518,7 +516,7 @@ GitEngine.prototype.getOrMakeRecursive = function(
if (type == 'HEAD') {
var headJSON = tree.HEAD;
var HEAD = new Ref(_.extend(
var HEAD = new Ref(Object.assign(
tree.HEAD,
{
target: this.getOrMakeRecursive(tree, createdSoFar, headJSON.target)
@ -531,7 +529,7 @@ GitEngine.prototype.getOrMakeRecursive = function(
if (type == 'branch') {
var branchJSON = tree.branches[objID];
var branch = new Branch(_.extend(
var branch = new Branch(Object.assign(
tree.branches[objID],
{
target: this.getOrMakeRecursive(tree, createdSoFar, branchJSON.target)
@ -544,7 +542,7 @@ GitEngine.prototype.getOrMakeRecursive = function(
if (type == 'tag') {
var tagJSON = tree.tags[objID];
var tag = new Tag(_.extend(
var tag = new Tag(Object.assign(
tree.tags[objID],
{
target: this.getOrMakeRecursive(tree, createdSoFar, tagJSON.target)
@ -558,12 +556,11 @@ GitEngine.prototype.getOrMakeRecursive = function(
// for commits, we need to grab all the parents
var commitJSON = tree.commits[objID];
var parentObjs = [];
_.each(commitJSON.parents, function(parentID) {
parentObjs.push(this.getOrMakeRecursive(tree, createdSoFar, parentID));
var parentObjs = commitJSON.parents.map(function(parentID) {
return this.getOrMakeRecursive(tree, createdSoFar, parentID);
}, this);
var commit = new Commit(_.extend(
var commit = new Commit(Object.assign(
commitJSON,
{
parents: parentObjs,
@ -726,7 +723,7 @@ GitEngine.prototype.makeTag = function(id, target) {
};
GitEngine.prototype.getHead = function() {
return _.clone(this.HEAD);
return Object.assign({}, this.HEAD);
};
GitEngine.prototype.getTags = function() {
@ -758,14 +755,14 @@ GitEngine.prototype.getBranches = function() {
GitEngine.prototype.getRemoteBranches = function() {
var all = this.getBranches();
return _.filter(all, function(branchJSON) {
return all.filter(function(branchJSON) {
return branchJSON.remote === true;
});
};
GitEngine.prototype.getLocalBranches = function() {
var all = this.getBranches();
return _.filter(all, function(branchJSON) {
return all.filter(function(branchJSON) {
return branchJSON.remote === false;
});
};
@ -774,17 +771,16 @@ GitEngine.prototype.printBranchesWithout = function(without) {
var commitToBranches = this.getUpstreamBranchSet();
var commitID = this.getCommitFromRef(without).get('id');
var toPrint = [];
_.each(commitToBranches[commitID], function(branchJSON) {
var toPrint = commitToBranches[commitID].map(function (branchJSON) {
branchJSON.selected = this.HEAD.get('target').get('id') == branchJSON.id;
toPrint.push(branchJSON);
return branchJSON;
}, this);
this.printBranches(toPrint);
};
GitEngine.prototype.printBranches = function(branches) {
var result = '';
_.each(branches, function(branch) {
branches.forEach(function (branch) {
result += (branch.selected ? '* ' : '') + branch.id + '\n';
});
throw new CommandResult({
@ -794,7 +790,7 @@ GitEngine.prototype.printBranches = function(branches) {
GitEngine.prototype.printTags = function(tags) {
var result = '';
_.each(tags, function(tag) {
tags.forEach(function (tag) {
result += tag.id + '\n';
});
throw new CommandResult({
@ -846,7 +842,7 @@ GitEngine.prototype.makeCommit = function(parents, id, options) {
id = this.getUniqueID();
}
var commit = new Commit(_.extend({
var commit = new Commit(Object.assign({
parents: parents,
id: id,
gitVisuals: this.gitVisuals
@ -861,7 +857,7 @@ GitEngine.prototype.makeCommit = function(parents, id, options) {
GitEngine.prototype.revert = function(whichCommits) {
// resolve the commits we will rebase
var toRevert = _.map(whichCommits, function(stringRef) {
var toRevert = whichCommits.map(function(stringRef) {
return this.getCommitFromRef(stringRef);
}, this);
@ -895,11 +891,11 @@ GitEngine.prototype.revert = function(whichCommits) {
}.bind(this);
// set up the promise chain
_.each(toRevert, function(commit) {
toRevert.forEach(function (commit) {
chain = chain.then(function() {
return chainStep(commit);
});
}, this);
});
// done! update our location
chain = chain.then(function() {
@ -934,7 +930,7 @@ GitEngine.prototype.setupCherrypickChain = function(toCherrypick) {
);
}.bind(this);
_.each(toCherrypick, function(arg) {
toCherrypick.forEach(function (arg) {
chain = chain.then(function() {
return chainStep(arg);
});
@ -1015,7 +1011,7 @@ GitEngine.prototype.getTargetGraphDifference = function(
while (toExplore.length) {
var here = toExplore.pop();
difference.push(here);
_.each(here.parents, pushParent);
here.parents.forEach(pushParent);
}
// filter because we weren't doing graph search
@ -1135,14 +1131,14 @@ GitEngine.prototype.push = function(options) {
// and remote master might be commits C2, C3, and C4, but the remote
// might already have those commits. In this case, we don't need to
// make them, so filter these out
commitsToMake = _.filter(commitsToMake, function(commitJSON) {
commitsToMake = commitsToMake.filter(function(commitJSON) {
return !this.origin.refs[commitJSON.id];
}, this);
var makeCommit = function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know
// the dependencies are there already
var parents = _.map(parentIDs, function(parentID) {
var parents = parentIDs.map(function(parentID) {
return this.origin.refs[parentID];
}, this);
return this.origin.makeCommit(parents, id);
@ -1160,7 +1156,7 @@ GitEngine.prototype.push = function(options) {
var deferred = Q.defer();
var chain = deferred.promise;
_.each(commitsToMake, function(commitJSON) {
commitsToMake.forEach(function(commitJSON) {
chain = chain.then(function() {
return this.animationFactory.playHighlightPromiseAnimation(
this.refs[commitJSON.id],
@ -1250,7 +1246,7 @@ GitEngine.prototype.fetch = function(options) {
}
// get all remote branches and specify the dest / source pairs
var allBranchesOnRemote = this.origin.branchCollection.toArray();
var sourceDestPairs = _.map(allBranchesOnRemote, function(branch) {
var sourceDestPairs = allBranchesOnRemote.map(function(branch) {
var branchName = branch.get('id');
didMakeBranch = didMakeBranch || this.makeRemoteBranchIfNeeded(branchName);
@ -1267,7 +1263,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
// first check if our local remote branch is upstream of the origin branch set.
// this check essentially pretends the local remote branch is in origin and
// could be fast forwarded (basic sanity check)
_.each(sourceDestPairs, function(pair) {
sourceDestPairs.forEach(function (pair) {
this.checkUpstreamOfSource(
this,
this.origin,
@ -1278,13 +1274,13 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
// then we get the difference in commits between these two graphs
var commitsToMake = [];
_.each(sourceDestPairs, function(pair) {
sourceDestPairs.forEach(function (pair) {
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
this,
this.origin,
pair.destination,
pair.source,
_.extend(
Object.assign(
{},
options,
{dontThrowOnNoFetch: true}
@ -1309,14 +1305,14 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
// and remote master might be commits C2, C3, and C4, but we
// might already have those commits. In this case, we don't need to
// make them, so filter these out
commitsToMake = _.filter(commitsToMake, function(commitJSON) {
commitsToMake = commitsToMake.filter(function(commitJSON) {
return !this.refs[commitJSON.id];
}, this);
var makeCommit = function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know
// the dependencies are there already
var parents = _.map(parentIDs, function(parentID) {
var parents = parentIDs.map(function(parentID) {
return this.refs[parentID];
}, this);
return this.makeCommit(parents, id);
@ -1341,7 +1337,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
}
var originBranchSet = this.origin.getUpstreamBranchSet();
_.each(commitsToMake, function(commitJSON) {
commitsToMake.forEach(function (commitJSON) {
// technically we could grab the wrong one here
// but this works for now
var originBranch = originBranchSet[commitJSON.id][0].obj;
@ -1364,7 +1360,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
chain = chain.then(function() {
// update all the destinations
_.each(sourceDestPairs, function(pair) {
sourceDestPairs.forEach(function (pair) {
var ours = this.refs[pair.destination];
var theirCommitID = this.origin.getCommitFromRef(pair.source).get('id');
// by definition we just made the commit with this id,
@ -1555,11 +1551,9 @@ GitEngine.prototype.fakeTeamwork = function(numToMake, branch) {
var deferred = Q.defer();
var chain = deferred.promise;
_.each(_.range(numToMake), function(i) {
chain = chain.then(function() {
return chainStep();
});
});
for(var i = 0; i < numToMake; i++) {
chain = chain.then(chainStep);
}
this.animationQueue.thenFinish(chain, deferred);
};
@ -1736,13 +1730,13 @@ GitEngine.prototype.updateBranchesFromSet = function(commitSet) {
var branchesToUpdate = {};
// now loop over the set we got passed in and find which branches
// that means (aka intersection)
_.each(commitSet, function(val, id) {
_.each(upstreamSet[id], function(branchJSON) {
commitSet.forEach(function (val, id) {
upstreamSet[id].forEach(function (branchJSON) {
branchesToUpdate[branchJSON.id] = true;
});
}, this);
var branchList = _.map(branchesToUpdate, function(val, id) {
var branchList = branchesToUpdate.map(function(val, id) {
return id;
});
return this.updateBranchesForHg(branchList);
@ -1777,7 +1771,7 @@ GitEngine.prototype.syncRemoteBranchFills = function() {
GitEngine.prototype.updateBranchesForHg = function(branchList) {
var hasUpdated = false;
_.each(branchList, function(branchID) {
branchList.forEach(function (branchID) {
// ok now just check if this branch has a more recent commit available.
// that mapping is easy because we always do rebase alt id --
// theres no way to have C3' and C3''' but no C3''. so just
@ -1808,7 +1802,7 @@ GitEngine.prototype.updateBranchesForHg = function(branchList) {
GitEngine.prototype.updateCommitParentsForHgRebase = function(commitSet) {
var anyChange = false;
_.each(commitSet, function(val, commitID) {
Object.keys(commitSet).forEach(function(commitID) {
var commit = this.refs[commitID];
var thisUpdated = commit.checkForUpdatedParent(this);
anyChange = anyChange || thisUpdated;
@ -1825,7 +1819,7 @@ GitEngine.prototype.pruneTree = function() {
var set = this.getUpstreamBranchSet();
// don't prune commits that HEAD depends on
var headSet = Graph.getUpstreamSet(this, 'HEAD');
_.each(headSet, function(val, commitID) {
Object.keys(headSet).forEach(function(commitID) {
set[commitID] = true;
});
@ -1846,7 +1840,7 @@ GitEngine.prototype.pruneTree = function() {
this.command.addWarning(intl.str('hg-prune-tree'));
}
_.each(toDelete, function(commit) {
toDelete.forEach(function (commit) {
commit.removeFromParents();
this.commitCollection.remove(commit);
@ -1877,7 +1871,7 @@ GitEngine.prototype.getUpstreamCollectionSet = function(collection) {
var inArray = function(arr, id) {
var found = false;
_.each(arr, function(wrapper) {
arr.forEach(function (wrapper) {
if (wrapper.id == id) {
found = true;
}
@ -1902,7 +1896,7 @@ GitEngine.prototype.getUpstreamCollectionSet = function(collection) {
collection.each(function(ref) {
var set = bfsSearch(ref.get('target'));
_.each(set, function(id) {
set.forEach(function (id) {
commitToSet[id] = commitToSet[id] || [];
// only add it if it's not there, so hue blending is ok
@ -2072,14 +2066,14 @@ GitEngine.prototype.hgRebase = function(destination, base) {
// and NOWWWwwww get all the descendants of this set
var moreSets = [];
_.each(upstream, function(val, id) {
Object.keys(upstream).forEach(function(id) {
moreSets.push(this.getDownstreamSet(id));
}, this);
var masterSet = {};
masterSet[baseCommit.get('id')] = true;
_.each([upstream, downstream].concat(moreSets), function(set) {
_.each(set, function(val, id) {
[upstream, downstream].concat(moreSets).forEach(function(set) {
Object.keys(set).forEach(function(id) {
masterSet[id] = true;
});
});
@ -2087,16 +2081,14 @@ GitEngine.prototype.hgRebase = function(destination, base) {
// we also need the branches POINTING to master set
var branchMap = {};
var upstreamSet = this.getUpstreamBranchSet();
_.each(masterSet, function(val, commitID) {
Object.keys(masterSet).forEach(function(commitID) {
// now loop over that commits branches
_.each(upstreamSet[commitID], function(branchJSON) {
upstreamSet[commitID].forEach(function(branchJSON) {
branchMap[branchJSON.id] = true;
});
});
var branchList = _.map(branchMap, function(val, id) {
return id;
});
var branchList = Object.keys(branchMap);
chain = chain.then(function() {
// now we just moved a bunch of commits, but we haven't updated the
@ -2156,7 +2148,7 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation, options) {
GitEngine.prototype.getUpstreamDiffSetFromSet = function(stopSet, location) {
var set = {};
_.each(this.getUpstreamDiffFromSet(stopSet, location), function(commit) {
this.getUpstreamDiffFromSet(stopSet, location).forEach(function (commit) {
set[commit.get('id')] = true;
});
return set;
@ -2189,7 +2181,7 @@ GitEngine.prototype.getInteractiveRebaseCommits = function(targetSource, current
// throw out merge's real fast and see if we have anything to do
var toRebase = [];
_.each(toRebaseRough, function(commit) {
toRebaseRough.forEach(function (commit) {
if (commit.get('parents').length == 1) {
toRebase.push(commit);
}
@ -2211,7 +2203,7 @@ GitEngine.prototype.rebaseInteractiveTest = function(targetSource, currentLocati
var toRebase = this.getInteractiveRebaseCommits(targetSource, currentLocation);
var rebaseMap = {};
_.each(toRebase, function(commit) {
toRebase.forEach(function (commit) {
var id = commit.get('id');
rebaseMap[id] = commit;
});
@ -2228,7 +2220,7 @@ GitEngine.prototype.rebaseInteractiveTest = function(targetSource, currentLocati
// Verify each chosen commit exists in the list of commits given to the user
var extraCommits = [];
rebaseOrder = [];
_.each(idsToRebase, function(id) {
idsToRebase.forEach(function (id) {
if (id in rebaseMap) {
rebaseOrder.push(rebaseMap[id]);
} else {
@ -2281,13 +2273,13 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation,
var initialCommitOrdering;
if (options.initialCommitOrdering && options.initialCommitOrdering.length > 0) {
var rebaseMap = {};
_.each(toRebase, function(commit) {
toRebase.forEach(function (commit) {
rebaseMap[commit.get('id')] = true;
});
// Verify each chosen commit exists in the list of commits given to the user
initialCommitOrdering = [];
_.each(options.initialCommitOrdering[0].split(','), function(id) {
options.initialCommitOrdering[0].split(',').forEach(function (id) {
if (!rebaseMap[id]) {
throw new GitError({
msg: intl.todo('Hey those commits don\'t exist in the set!')
@ -2313,13 +2305,13 @@ GitEngine.prototype.filterRebaseCommits = function(
options
) {
var changesAlreadyMade = {};
_.each(stopSet, function(val, key) {
Object.keys(stopSet).forEach(function(key) {
changesAlreadyMade[this.scrapeBaseID(key)] = true;
}, this);
var uniqueIDs = {};
// resolve the commits we will rebase
return _.filter(toRebaseRough, function(commit) {
return toRebaseRough.filter(function(commit) {
// no merge commits, unless we preserve
if (commit.get('parents').length !== 1 && !options.preserveMerges) {
return false;
@ -2344,7 +2336,7 @@ GitEngine.prototype.filterRebaseCommits = function(
GitEngine.prototype.getRebasePreserveMergesParents = function(oldCommit) {
var oldParents = oldCommit.get('parents');
return _.map(oldParents, function(parent) {
return oldParents.map(function(parent) {
var oldID = parent.get('id');
var newID = this.getMostRecentBumpedID(oldID);
return this.refs[newID];
@ -2406,7 +2398,7 @@ GitEngine.prototype.rebaseFinish = function(
}.bind(this);
// set up the promise chain
_.each(toRebase, function(commit) {
toRebase.forEach(function (commit) {
chain = chain.then(function() {
return chainStep(commit);
});
@ -2561,7 +2553,7 @@ GitEngine.prototype.describe = function(ref) {
// ok we need to BFS from start upwards until we hit a tag. but
// first we need to get a reverse mapping from tag to commit
var tagMap = {};
_.each(this.tagCollection.toJSON(), function(tag) {
this.tagCollection.toJSON().forEach(function (tag) {
tagMap[tag.target.get('id')] = tag.id;
});
@ -2733,7 +2725,7 @@ GitEngine.prototype.status = function() {
lines.push(intl.str('git-status-readytocommit'));
var msg = '';
_.each(lines, function(line) {
lines.forEach(function (line) {
msg += '# ' + line + '\n';
});
@ -2776,7 +2768,7 @@ GitEngine.prototype.log = function(ref, omitSet) {
// now go through and collect logs
var bigLogStr = '';
_.each(toDump, function(c) {
toDump.forEach(function (c) {
bigLogStr += c.getLogEntry();
}, this);
@ -2831,7 +2823,7 @@ GitEngine.prototype.getDownstreamSet = function(ancestor) {
var here = queue.pop();
var children = here.get('children');
_.each(children, addToExplored);
children.forEach(addToExplored);
}
return exploredSet;
};
@ -3009,7 +3001,7 @@ var Commit = Backbone.Model.extend({
},
removeFromParents: function() {
_.each(this.get('parents'), function(parent) {
this.get('parents').forEach(function (parent) {
parent.removeChild(this);
}, this);
},
@ -3052,11 +3044,11 @@ var Commit = Backbone.Model.extend({
removeChild: function(childToRemove) {
var newChildren = [];
_.each(this.get('children'), function(child) {
this.get('children').forEach(function (child) {
if (child !== childToRemove) {
newChildren.push(child);
}
}, this);
});
this.set('children', newChildren);
},
@ -3069,7 +3061,7 @@ var Commit = Backbone.Model.extend({
this.validateAtInit();
this.addNodeToVisuals();
_.each(this.get('parents'), function(parent) {
(this.get('parents') || []).forEach(function (parent) {
parent.get('children').push(this);
this.addEdgeToVisuals(parent);
}, this);

View file

@ -1,5 +1,3 @@
var _ = require('underscore');
function invariant(truthy, reason) {
if (!truthy) {
throw new Error(reason);
@ -44,7 +42,7 @@ var Graph = {
if (type == 'HEAD') {
var headJSON = tree.HEAD;
var HEAD = new Ref(_.extend(
var HEAD = new Ref(Object.assign(
tree.HEAD,
{
target: this.getOrMakeRecursive(tree, createdSoFar, headJSON.target)
@ -57,7 +55,7 @@ var Graph = {
if (type == 'branch') {
var branchJSON = tree.branches[objID];
var branch = new Branch(_.extend(
var branch = new Branch(Object.assign(
tree.branches[objID],
{
target: this.getOrMakeRecursive(tree, createdSoFar, branchJSON.target)
@ -70,7 +68,7 @@ var Graph = {
if (type == 'tag') {
var tagJSON = tree.tags[objID];
var tag = new Tag(_.extend(
var tag = new Tag(Object.assign(
tree.tags[objID],
{
target: this.getOrMakeRecursive(tree, createdSoFar, tagJSON.target)
@ -85,11 +83,11 @@ var Graph = {
var commitJSON = tree.commits[objID];
var parentObjs = [];
_.each(commitJSON.parents, function(parentID) {
commitJSON.parents.forEach(function(parentID) {
parentObjs.push(this.getOrMakeRecursive(tree, createdSoFar, parentID));
}, this);
var commit = new Commit(_.extend(
var commit = new Commit(Object.assign(
commitJSON,
{
parents: parentObjs,
@ -143,7 +141,7 @@ var Graph = {
var here = queue.pop();
var rents = here.get('parents');
_.each(rents, addToExplored);
(rents || []).forEach(addToExplored);
}
return exploredSet;
},
@ -151,7 +149,7 @@ var Graph = {
getUniqueObjects: function(objects) {
var unique = {};
var result = [];
_.forEach(objects, function(object) {
objects.forEach(function(object) {
if (unique[object.id]) {
return;
}

View file

@ -92,7 +92,7 @@ TreeCompare.compareAllBranchesWithinTrees = function(treeA, treeB) {
treeA = this.convertTreeSafe(treeA);
treeB = this.convertTreeSafe(treeB);
var allBranches = _.extend(
var allBranches = Object.assign(
{},
treeA.branches,
treeB.branches
@ -115,7 +115,7 @@ TreeCompare.compareAllTagsWithinTrees = function(treeA, treeB) {
TreeCompare.compareBranchesWithinTrees = function(treeA, treeB, branches) {
var result = true;
_.each(branches, function(branchName) {
branches.forEach(function(branchName) {
result = result && this.compareBranchWithinTrees(treeA, treeB, branchName);
}, this);
@ -140,13 +140,12 @@ TreeCompare.compareAllBranchesWithinTreesHashAgnostic = function(treeA, treeB) {
treeB = this.convertTreeSafe(treeB);
this.reduceTreeFields([treeA, treeB]);
var allBranches = _.extend(
var allBranches = Object.assign(
{},
treeA.branches,
treeB.branches
);
var branchNames = [];
_.each(allBranches, function(obj, name) { branchNames.push(name); });
var branchNames = Object.keys(allBranches || {});
return this.compareBranchesWithinTreesHashAgnostic(treeA, treeB, branchNames);
};
@ -165,8 +164,8 @@ TreeCompare.compareBranchesWithinTreesHashAgnostic = function(treeA, treeB, bran
}
// don't mess up the rest of comparison
branchA = _.clone(branchA);
branchB = _.clone(branchB);
branchA = Object.assign({}, branchA);
branchB = Object.assign({}, branchB);
branchA.target = this.getBaseRef(branchA.target);
branchB.target = this.getBaseRef(branchB.target);
@ -176,7 +175,7 @@ TreeCompare.compareBranchesWithinTreesHashAgnostic = function(treeA, treeB, bran
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
var result = true;
_.each(branches, function(branchName) {
branches.forEach(function(branchName) {
var branchA = treeA.branches[branchName];
var branchB = treeB.branches[branchName];
@ -188,7 +187,8 @@ TreeCompare.compareBranchesWithinTreesHashAgnostic = function(treeA, treeB, bran
TreeCompare.evalAsserts = function(tree, assertsPerBranch) {
var result = true;
_.each(assertsPerBranch, function(asserts, branchName) {
Object.keys(assertsPerBranch).forEach(function(branchName) {
var asserts = assertsPerBranch[branchName];
result = result && this.evalAssertsOnBranch(tree, branchName, asserts);
}, this);
return result;
@ -217,7 +217,7 @@ TreeCompare.evalAssertsOnBranch = function(tree, branchName, asserts) {
}
var result = true;
_.each(asserts, function(assert) {
asserts.forEach(function(assert) {
try {
result = result && assert(data);
} catch (err) {
@ -270,7 +270,7 @@ TreeCompare.getRecurseCompareHashAgnostic = function(treeA, treeB) {
// some buildup functions
var getStrippedCommitCopy = function(commit) {
if (!commit) { return {}; }
return _.extend(
return Object.assign(
{},
commit,
{
@ -305,7 +305,7 @@ TreeCompare.getRecurseCompare = function(treeA, treeB, options) {
// so the index lookup is valid. for merge commits this will duplicate some of the
// checking (because we aren't doing graph search) but it's not a huge deal
var maxNumParents = Math.max(commitA.parents.length, commitB.parents.length);
_.each(_.range(maxNumParents), function(index) {
for (var index = 0; index < maxNumParents; index++) {
var pAid = commitA.parents[index];
var pBid = commitB.parents[index];
@ -315,7 +315,7 @@ TreeCompare.getRecurseCompare = function(treeA, treeB, options) {
var childB = treeB.commits[pBid];
result = result && recurseCompare(childA, childB);
}, this);
}
// if each of our children recursively are equal, we are good
return result;
};
@ -327,9 +327,10 @@ TreeCompare.lowercaseTree = function(tree) {
tree.HEAD.target = tree.HEAD.target.toLocaleLowerCase();
}
var branches = tree.branches;
var branches = tree.branches || {};
tree.branches = {};
_.each(branches, function(obj, name) {
Object.keys(branches).forEach(function(name) {
var obj = branches[name];
obj.id = obj.id.toLocaleLowerCase();
tree.branches[name.toLocaleLowerCase()] = obj;
});
@ -377,8 +378,9 @@ TreeCompare.reduceTreeFields = function(trees) {
tags: {}
};
_.each(trees, function(tree) {
_.each(treeDefaults, function(val, key) {
trees.forEach(function(tree) {
Object.keys(treeDefaults).forEach(function(key) {
var val = treeDefaults[key];
if (tree[key] === undefined) {
tree[key] = val;
}
@ -388,10 +390,11 @@ TreeCompare.reduceTreeFields = function(trees) {
// this function saves only the specified fields of a tree
var saveOnly = function(tree, treeKey, saveFields, sortFields) {
var objects = tree[treeKey];
_.each(objects, function(obj, objKey) {
Object.keys(objects).forEach(function(objKey) {
var obj = objects[objKey];
// our blank slate to copy over
var blank = {};
_.each(saveFields, function(field) {
saveFields.forEach(function(field) {
if (obj[field] !== undefined) {
blank[field] = obj[field];
} else if (defaults[field] !== undefined) {
@ -399,7 +402,7 @@ TreeCompare.reduceTreeFields = function(trees) {
}
});
_.each(sortFields, function(field) {
Object.values(sortFields || {}).forEach(function(field) {
// also sort some fields
if (obj[field]) {
obj[field].sort();
@ -410,7 +413,7 @@ TreeCompare.reduceTreeFields = function(trees) {
});
};
_.each(trees, function(tree) {
trees.forEach(function(tree) {
saveOnly(tree, 'commits', commitSaveFields, commitSortFields);
saveOnly(tree, 'branches', branchSaveFields);
saveOnly(tree, 'tags', tagSaveFields);

View file

@ -11,7 +11,7 @@ var fallbackMap = {
// lets change underscores template settings so it interpolates
// things like "{branchName} does not exist".
var templateSettings = _.clone(_.templateSettings);
var templateSettings = Object.assign({}, _.templateSettings);
templateSettings.interpolate = /\{(.+?)\}/g;
var template = exports.template = function(str, params) {
return _.template(str, params, templateSettings);
@ -106,7 +106,8 @@ exports.getStartDialog = function(level) {
markdown: str('error-untranslated')
}
};
var startCopy = _.clone(
var startCopy = Object.assign(
{},
level.startDialog[getDefaultLocale()] || level.startDialog
);
startCopy.childViews.unshift(errorAlert);

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone');
var Q = require('q');
@ -360,7 +359,7 @@ var LevelBuilder = Level.extend({
},
getExportObj: function() {
var compiledLevel = _.extend(
var compiledLevel = Object.assign(
{},
this.level
);

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Q = require('q');
var util = require('../util');
@ -70,7 +69,7 @@ var Level = Sandbox.extend({
// if there is a multiview in the beginning, open that
// and let it resolve our deferred
if (this.level.startDialog && !this.testOption('noIntroDialog')) {
new MultiView(_.extend(
new MultiView(Object.assign(
{},
intl.getStartDialog(this.level),
{ deferred: deferred }
@ -99,7 +98,7 @@ var Level = Sandbox.extend({
var dialog = $.extend({}, intl.getStartDialog(levelObj));
// grab the last slide only
dialog.childViews = dialog.childViews.slice(-1);
new MultiView(_.extend(
new MultiView(Object.assign(
dialog,
{ deferred: deferred }
));
@ -406,8 +405,9 @@ var Level = Sandbox.extend({
}
var matched = false;
_.each(Commands.commands.getCommandsThatCount(), function(map) {
_.each(map, function(regex) {
var commandsThatCount = Commands.commands.getCommandsThatCount();
Object.values(commandsThatCount).forEach(function(map) {
Object.values(map).forEach(function(regex) {
matched = matched || regex.test(command.get('rawStr'));
});
});

View file

@ -1,5 +1,3 @@
var _ = require('underscore');
var GitCommands = require('../git/commands');
var Commands = require('../commands');
var SandboxCommands = require('../sandbox/commands');
@ -68,15 +66,17 @@ ParseWaterfall.prototype.addLast = function(which, value) {
};
ParseWaterfall.prototype.expandAllShortcuts = function(commandStr) {
_.each(this.shortcutWaterfall, function(shortcutMap) {
this.shortcutWaterfall.forEach(function(shortcutMap) {
commandStr = this.expandShortcut(commandStr, shortcutMap);
}, this);
return commandStr;
};
ParseWaterfall.prototype.expandShortcut = function(commandStr, shortcutMap) {
_.each(shortcutMap, function(map, vcs) {
_.each(map, function(regex, method) {
Object.keys(shortcutMap).forEach(function(vcs) {
var map = shortcutMap[vcs];
Object.keys(map).forEach(function(method) {
var regex = map[method];
var results = regex.exec(commandStr);
if (results) {
commandStr = vcs + ' ' + method + ' ' + commandStr.slice(results[0].length);
@ -87,13 +87,13 @@ ParseWaterfall.prototype.expandShortcut = function(commandStr, shortcutMap) {
};
ParseWaterfall.prototype.processAllInstants = function(commandStr) {
_.each(this.instantWaterfall, function(instantCommands) {
this.instantWaterfall.forEach(function(instantCommands) {
this.processInstant(commandStr, instantCommands);
}, this);
};
ParseWaterfall.prototype.processInstant = function(commandStr, instantCommands) {
_.each(instantCommands, function(tuple) {
instantCommands.forEach(function(tuple) {
var regex = tuple[0];
var results = regex.exec(commandStr);
if (results) {
@ -109,7 +109,7 @@ ParseWaterfall.prototype.parseAll = function(commandStr) {
}
var toReturn = false;
_.each(this.parseWaterfall, function(parseFunc) {
this.parseWaterfall.forEach(function(parseFunc) {
var results = parseFunc(commandStr);
if (results) {
toReturn = results;
@ -120,4 +120,3 @@ ParseWaterfall.prototype.parseAll = function(commandStr) {
};
exports.ParseWaterfall = ParseWaterfall;

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone');
var Errors = require('../util/errors');
@ -78,12 +77,13 @@ var Command = Backbone.Model.extend({
var generalArgs = this.getGeneralArgs();
var options = this.getOptionsMap();
generalArgs = _.map(generalArgs, function(arg) {
generalArgs = generalArgs.map(function(arg) {
return this.replaceDotWithHead(arg);
}, this);
var newMap = {};
_.each(options, function(args, key) {
newMap[key] = _.map(args, function(arg) {
Object.keys(options).forEach(function(key) {
var args = options[key];
newMap[key] = Object.values(args).map(function (arg) {
return this.replaceDotWithHead(arg);
}, this);
}, this);
@ -93,7 +93,7 @@ var Command = Backbone.Model.extend({
deleteOptions: function(options) {
var map = this.getOptionsMap();
_.each(options, function(option) {
options.forEach(function(option) {
delete map[option];
}, this);
this.setOptionsMap(map);
@ -273,7 +273,8 @@ var Command = Backbone.Model.extend({
return false;
}
_.each(results.toSet, function(obj, key) {
Object.keys(results.toSet).forEach(function(key) {
var obj = results.toSet[key];
// data comes back from the parsing functions like
// options (etc) that need to be set
this.set(key, obj);

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var util = require('../util');
var constants = require('../util/constants');
@ -98,7 +97,7 @@ var instantCommands = [
intl.str('show-all-commands'),
'<br/>'
];
_.each(allCommands, function(regex, command) {
allCommands.forEach(function(regex, command) {
lines.push(command);
});
@ -134,17 +133,20 @@ var getAllCommands = function() {
'mobileAlert'
];
var allCommands = _.extend(
var allCommands = Object.assign(
{},
require('../level').regexMap,
regexMap
);
_.each(Commands.commands.getRegexMap(), function(map, vcs) {
_.each(map, function(regex, method) {
var mRegexMap = Commands.commands.getRegexMap();
Object.keys(mRegexMap).forEach(function(vcs) {
var map = mRegexMap[vcs];
Object.keys(map).forEach(function(method) {
var regex = map[method];
allCommands[vcs + ' ' + method] = regex;
});
});
_.each(toDelete, function(key) {
toDelete.forEach(function(key) {
delete allCommands[key];
});

View file

@ -41,7 +41,7 @@ var validateLevel = function(level) {
'solutionCommand'
];
_.each(requiredFields, function(field) {
requiredFields.forEach(function(field) {
if (level[field] === undefined) {
console.log(level);
throw new Error('I need this field for a level: ' + field);
@ -52,14 +52,15 @@ var validateLevel = function(level) {
/**
* Unpack the level sequences.
*/
_.each(levelSequences, function(levels, levelSequenceName) {
Object.keys(levelSequences).forEach(function(levelSequenceName) {
var levels = levelSequences[levelSequenceName];
_sequences.push(levelSequenceName);
if (!levels || !levels.length) {
throw new Error('no empty sequences allowed');
}
// for this particular sequence...
_.each(levels, function(level, index) {
levels.forEach(function(level, index) {
validateLevel(level);
var id = levelSequenceName + String(index + 1);
@ -89,7 +90,7 @@ AppConstants.StoreSubscribePrototype,
},
getSequences: function() {
return _.keys(levelSequences);
return Object.keys(levelSequences);
},
getLevelsInSequence: function(sequenceName) {

View file

@ -179,7 +179,7 @@ var DemonstrationBuilder = ContainedBase.extend({
this.deferred = options.deferred || Q.defer();
if (options.fromObj) {
var toEdit = options.fromObj.options;
options = _.extend(
options = Object.assign(
{},
options,
toEdit,
@ -295,7 +295,7 @@ var MultiViewBuilder = ContainedBase.extend({
this.JSON = {
views: this.getChildViews(),
supportedViews: _.keys(this.typeToConstructor)
supportedViews: Object.keys(this.typeToConstructor)
};
this.container = new ModalTerminal({
@ -416,4 +416,3 @@ exports.DemonstrationBuilder = DemonstrationBuilder;
exports.TextGrabber = TextGrabber;
exports.MultiViewBuilder = MultiViewBuilder;
exports.MarkdownPresenter = MarkdownPresenter;

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone');
var Main = require('../app');
@ -173,7 +172,7 @@ var CommandPromptView = Backbone.View.extend({
which.reverse();
var str = '';
_.each(which, function(text) {
which.forEach(function(text) {
str += text + ';';
}, this);
@ -202,4 +201,3 @@ var CommandPromptView = Backbone.View.extend({
});
exports.CommandPromptView = CommandPromptView;

View file

@ -25,7 +25,7 @@ var GitDemonstrationView = ContainedBase.extend({
initialize: function(options) {
options = options || {};
this.options = options;
this.JSON = _.extend(
this.JSON = Object.assign(
{
beforeMarkdowns: [
'## Git Commits',
@ -55,7 +55,7 @@ var GitDemonstrationView = ContainedBase.extend({
this.render();
this.checkScroll();
this.navEvents = _.clone(Backbone.Events);
this.navEvents = Object.assign({}, Backbone.Events);
this.navEvents.on('positive', this.positive, this);
this.navEvents.on('negative', this.negative, this);
this.keyboardListener = new KeyboardListener({
@ -83,9 +83,9 @@ var GitDemonstrationView = ContainedBase.extend({
},
checkScroll: function() {
var children = this.$('div.demonstrationText').children();
var heights = _.map(children, function(child) { return child.clientHeight; });
var totalHeight = _.reduce(heights, function(a, b) { return a + b; });
var children = this.$('div.demonstrationText').children().toArray();
var heights = children.map(function(child) { return child.clientHeight; });
var totalHeight = heights.reduce(function(a, b) { return a + b; });
if (totalHeight < this.$('div.demonstrationText').height()) {
this.$('div.demonstrationText').addClass('noLongText');
}
@ -168,7 +168,7 @@ var GitDemonstrationView = ContainedBase.extend({
var chainDeferred = Q.defer();
var chainPromise = chainDeferred.promise;
_.each(commands, function(command, index) {
commands.forEach(function(command, index) {
chainPromise = chainPromise.then(function() {
var myDefer = Q.defer();
this.mainVis.gitEngine.dispatch(command, myDefer);
@ -244,4 +244,3 @@ var GitDemonstrationView = ContainedBase.extend({
});
exports.GitDemonstrationView = GitDemonstrationView;

View file

@ -86,7 +86,7 @@ var GeneralButton = ContainedBase.extend({
initialize: function(options) {
options = options || {};
this.navEvents = options.navEvents || _.clone(Backbone.Events);
this.navEvents = options.navEvents || Object.assign({}, Backbone.Events);
this.destination = options.destination;
if (!this.destination) {
this.container = new ModalTerminal();
@ -160,7 +160,7 @@ var LeftRightView = PositiveNegativeBase.extend({
// events system to add support for git demonstration view taking control of the
// click events
this.pipeEvents = options.events;
this.navEvents = _.clone(Backbone.Events);
this.navEvents = Object.assign({}, Backbone.Events);
this.JSON = {
showLeft: (options.showLeft === undefined) ? true : options.showLeft,
@ -305,7 +305,7 @@ var ModalTerminal = ContainedBase.extend({
initialize: function(options) {
options = options || {};
this.navEvents = options.events || _.clone(Backbone.Events);
this.navEvents = options.events || Object.assign({}, Backbone.Events);
this.container = new ModalView();
this.JSON = {
@ -372,7 +372,7 @@ var ConfirmCancelTerminal = Backbone.View.extend({
options = options || {};
this.deferred = options.deferred || Q.defer();
this.modalAlert = new ModalAlert(_.extend(
this.modalAlert = new ModalAlert(Object.assign(
{},
{ markdown: '#you sure?' },
options
@ -395,7 +395,7 @@ var ConfirmCancelTerminal = Backbone.View.extend({
}.bind(this));
// also setup keyboard
this.navEvents = _.clone(Backbone.Events);
this.navEvents = Object.assign({}, Backbone.Events);
this.navEvents.on('positive', this.positive, this);
this.navEvents.on('negative', this.negative, this);
this.keyboardListener = new KeyboardListener({
@ -470,7 +470,7 @@ var NextLevelConfirm = ConfirmCancelTerminal.extend({
'</p>';
}
options = _.extend(
options = Object.assign(
{},
options,
{

View file

@ -40,7 +40,7 @@ var LevelDropdownView = ContainedBase.extend({
}]
};
this.navEvents = _.clone(Backbone.Events);
this.navEvents = Object.assign({}, Backbone.Events);
this.navEvents.on('clickedID', _.debounce(
this.loadLevelID.bind(this),
300,
@ -211,7 +211,7 @@ var LevelDropdownView = ContainedBase.extend({
},
getTabIndex: function() {
var ids = _.map(this.JSON.tabs, function(tab) {
var ids = this.JSON.tabs.map(function(tab) {
return tab.id;
});
return ids.indexOf(this.JSON.selectedTab);
@ -235,7 +235,7 @@ var LevelDropdownView = ContainedBase.extend({
},
getSequencesOnTab: function() {
return _.filter(this.sequences, function(sequenceName) {
return this.sequences.filter(function(sequenceName) {
var tab = LEVELS.getTabForSequence(sequenceName);
return tab === this.JSON.selectedTab;
}, this);
@ -292,7 +292,7 @@ var LevelDropdownView = ContainedBase.extend({
$(selector).toggleClass('selected', value);
// also go find the series and update the about
_.each(this.seriesViews, function(view) {
this.seriesViews.forEach(function(view) {
if (view.levelIDs.indexOf(id) === -1) {
return;
}
@ -343,14 +343,14 @@ var LevelDropdownView = ContainedBase.extend({
},
updateSolvedStatus: function() {
_.each(this.seriesViews, function(view) {
this.seriesViews.forEach(function(view) {
view.updateSolvedStatus();
}, this);
},
buildSequences: function() {
this.seriesViews = [];
_.each(this.getSequencesOnTab(), function(sequenceName) {
this.getSequencesOnTab().forEach(function(sequenceName) {
this.seriesViews.push(new SeriesView({
destination: this.$el,
name: sequenceName,
@ -377,7 +377,7 @@ var SeriesView = BaseView.extend({
this.levelIDs = [];
var firstLevelInfo = null;
_.each(this.levels, function(level) {
this.levels.forEach(function(level) {
if (firstLevelInfo === null) {
firstLevelInfo = this.formatLevelAbout(level.id);
}
@ -444,4 +444,3 @@ var SeriesView = BaseView.extend({
});
exports.LevelDropdownView = LevelDropdownView;

View file

@ -48,7 +48,7 @@ var MultiView = Backbone.View.extend({
this.childViews = [];
this.currentIndex = 0;
this.navEvents = _.clone(Backbone.Events);
this.navEvents = Object.assign({}, Backbone.Events);
this.navEvents.on('negative', this.getNegFunc(), this);
this.navEvents.on('positive', this.getPosFunc(), this);
this.navEvents.on('quit', this.finish, this);
@ -142,7 +142,7 @@ var MultiView = Backbone.View.extend({
// other views will take if they need to
this.keyboardListener.mute();
_.each(this.childViews, function(childView) {
this.childViews.forEach(function(childView) {
childView.die();
});
@ -159,7 +159,7 @@ var MultiView = Backbone.View.extend({
if (!this.typeToConstructor[type]) {
throw new Error('no constructor for type "' + type + '"');
}
var view = new this.typeToConstructor[type](_.extend(
var view = new this.typeToConstructor[type](Object.assign(
{},
viewJSON.options,
{ wait: true }
@ -183,7 +183,7 @@ var MultiView = Backbone.View.extend({
render: function() {
// go through each and render... show the first
_.each(this.childViewJSONs, function(childViewJSON, index) {
this.childViewJSONs.forEach(function(childViewJSON, index) {
var childView = this.createChildView(childViewJSON);
this.childViews.push(childView);
this.addNavToView(childView, index);
@ -192,4 +192,3 @@ var MultiView = Backbone.View.extend({
});
exports.MultiView = MultiView;

View file

@ -19,7 +19,7 @@ var InteractiveRebaseView = ContainedBase.extend({
this.rebaseEntries = new RebaseEntryCollection();
options.toRebase.reverse();
_.each(options.toRebase, function(commit) {
options.toRebase.forEach(function(commit) {
var id = commit.get('id');
this.rebaseMap[id] = commit;
@ -63,7 +63,7 @@ var InteractiveRebaseView = ContainedBase.extend({
// now get the real array
var toRebase = [];
_.each(uiOrder, function(id) {
uiOrder.forEach(function(id) {
// the model pick check
if (this.entryObjMap[id].get('pick')) {
toRebase.unshift(this.rebaseMap[id]);
@ -78,7 +78,7 @@ var InteractiveRebaseView = ContainedBase.extend({
render: function() {
var json = {
num: _.keys(this.rebaseMap).length,
num: Object.keys(this.rebaseMap).length,
solutionOrder: this.options.initialCommitOrdering
};

View file

@ -58,7 +58,7 @@ GitVisuals.prototype.defer = function(action) {
};
GitVisuals.prototype.deferFlush = function() {
_.each(this.deferred, function(action) {
this.deferred.forEach(function(action) {
action();
}, this);
this.deferred = [];
@ -68,17 +68,17 @@ GitVisuals.prototype.resetAll = function() {
// make sure to copy these collections because we remove
// items in place and underscore is too dumb to detect length change
var edges = this.visEdgeCollection.toArray();
_.each(edges, function(visEdge) {
edges.forEach(function(visEdge) {
visEdge.remove();
}, this);
var branches = this.visBranchCollection.toArray();
_.each(branches, function(visBranch) {
branches.forEach(function(visBranch) {
visBranch.remove();
}, this);
var tags = this.visTagCollection.toArray();
_.each(tags, function(visTag) {
tags.forEach(function(visTag) {
visTag.remove();
}, this);
@ -332,7 +332,7 @@ GitVisuals.prototype.explodeNodes = function(speed) {
// are called unnecessarily when they have almost
// zero speed. would be interesting to see performance differences
var keepGoing = [];
_.each(funcs, function(func) {
funcs.forEach(function(func) {
if (func()) {
keepGoing.push(func);
}
@ -354,7 +354,7 @@ GitVisuals.prototype.explodeNodes = function(speed) {
GitVisuals.prototype.animateAllFromAttrToAttr = function(fromSnapshot, toSnapshot, idsToOmit) {
var animate = function(obj) {
var id = obj.getID();
if (_.include(idsToOmit, id)) {
if (idsToOmit.includes(id)) {
return;
}
@ -485,7 +485,7 @@ GitVisuals.prototype.getBlendedHuesForCommit = function(commit) {
GitVisuals.prototype.blendHuesFromBranchStack = function(branchStackArray) {
var hueStrings = [];
_.each(branchStackArray, function(branchWrapper) {
branchStackArray.forEach(function(branchWrapper) {
var fill = branchWrapper.obj.get('visBranch').get('fill');
if (fill.slice(0,3) !== 'hsb') {
@ -525,7 +525,7 @@ GitVisuals.prototype.getCommitUpstreamStatus = function(commit) {
GitVisuals.prototype.calcTagStacks = function() {
var tags = this.gitEngine.getTags();
var map = {};
_.each(tags, function(tag) {
tags.forEach(function(tag) {
var thisId = tag.target.get('id');
map[thisId] = map[thisId] || [];
@ -542,7 +542,7 @@ GitVisuals.prototype.calcTagStacks = function() {
GitVisuals.prototype.calcBranchStacks = function() {
var branches = this.gitEngine.getBranches();
var map = {};
_.each(branches, function(branch) {
branches.forEach(function(branch) {
var thisId = branch.target.get('id');
map[thisId] = map[thisId] || [];
@ -572,7 +572,7 @@ GitVisuals.prototype.calcWidth = function() {
GitVisuals.prototype.maxWidthRecursive = function(commit) {
var childrenTotalWidth = 0;
_.each(commit.get('children'), function(child) {
commit.get('children').forEach(function(child) {
// only include this if we are the "main" parent of
// this child
if (child.isMainParent(commit)) {
@ -601,14 +601,14 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max) {
// basic box-flex model
var totalFlex = 0;
var children = commit.get('children');
_.each(children, function(child) {
children.forEach(function(child) {
if (child.isMainParent(commit)) {
totalFlex += child.get('visNode').getMaxWidthScaled();
}
}, this);
var prevBound = min;
_.each(children, function(child, index) {
children.forEach(function(child, index) {
if (!child.isMainParent(commit)) {
return;
}
@ -777,7 +777,7 @@ GitVisuals.prototype.calcDepthRecursive = function(commit, depth) {
var children = commit.get('children');
var maxDepth = depth;
_.each(children, function(child) {
children.forEach(function(child) {
var d = this.calcDepthRecursive(child, depth + 1);
maxDepth = Math.max(d, maxDepth);
}, this);
@ -924,7 +924,7 @@ function blendHueStrings(hueStrings) {
var totalBright = 0;
var length = hueStrings.length;
_.each(hueStrings, function(hueString) {
hueStrings.forEach(function(hueString) {
var exploded = hueString.split('(')[1];
exploded = exploded.split(')')[0];
exploded = exploded.split(',');

View file

@ -1,9 +1,8 @@
var _ = require('underscore');
var Backbone = require('backbone');
var VisBase = Backbone.Model.extend({
removeKeys: function(keys) {
_.each(keys, function(key) {
keys.forEach(function(key) {
if (this.get(key)) {
this.get(key).remove();
}
@ -13,7 +12,7 @@ var VisBase = Backbone.Model.extend({
animateAttrKeys: function(keys, attrObj, speed, easing) {
// either we animate a specific subset of keys or all
// possible things we could animate
keys = _.extend(
keys = Object.assign(
{},
{
include: ['circle', 'arrow', 'rect', 'path', 'text'],
@ -25,15 +24,15 @@ var VisBase = Backbone.Model.extend({
var attr = this.getAttributes();
// safely insert this attribute into all the keys we want
_.each(keys.include, function(key) {
attr[key] = _.extend(
keys.include.forEach(function(key) {
attr[key] = Object.assign(
{},
attr[key],
attrObj
);
});
_.each(keys.exclude, function(key) {
keys.exclude.forEach(function(key) {
delete attr[key];
});
@ -42,4 +41,3 @@ var VisBase = Backbone.Model.extend({
});
exports.VisBase = VisBase;

View file

@ -1,9 +1,8 @@
var _ = require('underscore');
var Backbone = require('backbone');
var VisBase = Backbone.Model.extend({
removeKeys: function(keys) {
_.each(keys, function(key) {
keys.forEach(function(key) {
if (this.get(key)) {
this.get(key).remove();
}
@ -35,14 +34,14 @@ var VisBase = Backbone.Model.extend({
},
setAttrBase: function(keys, attr, instant, speed, easing) {
_.each(keys, function(key) {
keys.forEach(function(key) {
if (instant) {
this.get(key).attr(attr[key]);
} else {
this.get(key).stop();
this.get(key).animate(attr[key], speed, easing);
// some keys don't support animating too, so set those instantly here
_.forEach(this.getNonAnimateKeys(), function(nonAnimateKey) {
this.getNonAnimateKeys().forEach(function(nonAnimateKey) {
if (attr[key] && attr[key][nonAnimateKey] !== undefined) {
this.get(key).attr(nonAnimateKey, attr[key][nonAnimateKey]);
}
@ -58,7 +57,7 @@ var VisBase = Backbone.Model.extend({
animateAttrKeys: function(keys, attrObj, speed, easing) {
// either we animate a specific subset of keys or all
// possible things we could animate
keys = _.extend(
keys = Object.assign(
{},
{
include: ['circle', 'arrow', 'rect', 'path', 'text'],
@ -70,15 +69,15 @@ var VisBase = Backbone.Model.extend({
var attr = this.getAttributes();
// safely insert this attribute into all the keys we want
_.each(keys.include, function(key) {
attr[key] = _.extend(
keys.include.forEach(function(key) {
attr[key] = Object.assign(
{},
attr[key],
attrObj
);
});
_.each(keys.exclude, function(key) {
keys.exclude.forEach(function(key) {
delete attr[key];
});
@ -87,4 +86,3 @@ var VisBase = Backbone.Model.extend({
});
exports.VisBase = VisBase;

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone');
var GRAPHICS = require('../util/constants').GRAPHICS;
@ -167,7 +166,7 @@ var VisBranch = VisBase.extend({
var myArray = this.getBranchStackArray();
var index = -1;
_.each(myArray, function(branch, i) {
myArray.forEach(function(branch, i) {
if (branch.obj == this.get('branch')) {
index = i;
}
@ -279,7 +278,7 @@ var VisBranch = VisBase.extend({
arrowInnerLow,
arrowStartLow
];
_.each(coords, function(pos) {
coords.forEach(function(pos) {
pathStr += 'L' + toStringCoords(pos) + ' ';
}, this);
pathStr += 'z';
@ -309,7 +308,7 @@ var VisBranch = VisBase.extend({
}
var maxWidth = 0;
_.each(this.getBranchStackArray(), function(branch) {
this.getBranchStackArray().forEach(function(branch) {
maxWidth = Math.max(maxWidth, getTextWidth(
branch.obj.get('visBranch')
));
@ -432,7 +431,7 @@ var VisBranch = VisBase.extend({
// set CSS
var keys = ['text', 'rect', 'arrow'];
_.each(keys, function(key) {
keys.forEach(function(key) {
$(this.get(key).node).css(attr.css);
}, this);
@ -451,7 +450,7 @@ var VisBranch = VisBase.extend({
this.get('arrow')
];
_.each(objs, function(rObj) {
objs.forEach(function(rObj) {
rObj.click(this.onClick.bind(this));
}, this);
},
@ -577,4 +576,3 @@ var VisBranchCollection = Backbone.Collection.extend({
exports.VisBranchCollection = VisBranchCollection;
exports.VisBranch = VisBranch;
exports.randomHueString = randomHueString;

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone');
var GRAPHICS = require('../util/constants').GRAPHICS;
@ -15,7 +14,7 @@ var VisEdge = VisBase.extend({
validateAtInit: function() {
var required = ['tail', 'head'];
_.each(required, function(key) {
required.forEach(function(key) {
if (!this.get(key)) {
throw new Error(key + ' is required!');
}

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone');
var GRAPHICS = require('../util/constants').GRAPHICS;
@ -261,33 +260,33 @@ var VisNode = VisBase.extend({
},
setOutgoingEdgesOpacity: function(opacity) {
_.each(this.get('outgoingEdges'), function(edge) {
this.get('outgoingEdges').forEach(function(edge) {
edge.setOpacity(opacity);
});
},
animateOutgoingEdgesToAttr: function(snapShot, speed, easing) {
_.each(this.get('outgoingEdges'), function(edge) {
this.get('outgoingEdges').forEach(function(edge) {
var attr = snapShot[edge.getID()];
edge.animateToAttr(attr);
}, this);
},
animateOutgoingEdges: function(speed, easing) {
_.each(this.get('outgoingEdges'), function(edge) {
this.get('outgoingEdges').forEach(function(edge) {
edge.animateUpdatedPath(speed, easing);
}, this);
},
animateOutgoingEdgesFromSnapshot: function(snapshot, speed, easing) {
_.each(this.get('outgoingEdges'), function(edge) {
this.get('outgoingEdges').forEach(function(edge) {
var attr = snapshot[edge.getID()];
edge.animateToAttr(attr, speed, easing);
}, this);
},
setOutgoingEdgesBirthPosition: function(parentCoords) {
_.each(this.get('outgoingEdges'), function(edge) {
this.get('outgoingEdges').forEach(function(edge) {
var headPos = edge.get('head').getScreenCoords();
var path = edge.genSmoothBezierPathStringFromCoords(parentCoords, headPos);
edge.get('path').stop();
@ -334,7 +333,7 @@ var VisNode = VisBase.extend({
}
var commandStr = 'git checkout ' + this.get('commit').get('id');
var Main = require('../app');
_.each([this.get('circle'), this.get('text')], function(rObj) {
[this.get('circle'), this.get('text')].forEach(function(rObj) {
rObj.click(function() {
Main.getEventBaton().trigger('commandSubmitted', commandStr);
});
@ -347,7 +346,7 @@ var VisNode = VisBase.extend({
// set the opacity on my stuff
var keys = ['circle', 'text'];
_.each(keys, function(key) {
keys.forEach(function(key) {
this.get(key).attr({
opacity: opacity
});
@ -371,7 +370,7 @@ var VisNode = VisBase.extend({
},
removeAllEdges: function() {
_.each(this.get('outgoingEdges'), function(edge) {
this.get('outgoingEdges').forEach(function(edge) {
edge.remove();
}, this);
},

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone');
var GRAPHICS = require('../util/constants').GRAPHICS;
@ -95,7 +94,7 @@ var VisTag = VisBase.extend({
var myArray = this.getTagStackArray();
var index = -1;
_.each(myArray, function(Tag, i) {
myArray.forEach(function(Tag, i) {
if (Tag.obj == this.get('tag')) {
index = i;
}
@ -175,7 +174,7 @@ var VisTag = VisBase.extend({
var textNode = this.get('text').node;
var maxWidth = 0;
_.each(this.getTagStackArray(), function(Tag) {
this.getTagStackArray().forEach(function(Tag) {
maxWidth = Math.max(maxWidth, getTextWidth(
Tag.obj.get('visTag')
));
@ -271,7 +270,7 @@ var VisTag = VisBase.extend({
// set CSS
var keys = ['text', 'rect'];
_.each(keys, function(key) {
keys.forEach(function(key) {
$(this.get(key).node).css(attr.css);
}, this);
@ -289,7 +288,7 @@ var VisTag = VisBase.extend({
this.get('text')
];
_.each(objs, function(rObj) {
objs.forEach(function(rObj) {
rObj.click(this.onClick.bind(this));
}, this);
},
@ -405,4 +404,3 @@ var VisTagCollection = Backbone.Collection.extend({
exports.VisTagCollection = VisTagCollection;
exports.VisTag = VisTag;
exports.randomHueString = randomHueString;

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone');
var Collections = require('../models/collections');
@ -13,7 +12,7 @@ var Visualization = Backbone.View.extend({
initialize: function(options) {
options = options || {};
this.options = options;
this.customEvents = _.clone(Backbone.Events);
this.customEvents = Object.assign({}, Backbone.Events);
this.containerElement = options.containerElement;
var _this = this;
@ -104,7 +103,7 @@ var Visualization = Backbone.View.extend({
makeOrigin: function(options) {
// oh god, here we go. We basically do a bizarre form of composition here,
// where this visualization actually contains another one of itself.
this.originVis = new Visualization(_.extend(
this.originVis = new Visualization(Object.assign(
{},
// copy all of our options over, except...
this.options,