wip: starts upgrading lodash to v3

This commit is contained in:
Matteo Pagliazzi
2015-11-11 10:32:49 +01:00
parent 8f9d2a5f9a
commit 3795b1d151
13 changed files with 35 additions and 27 deletions

View File

@@ -11,7 +11,7 @@ function beastMasterProgress(pets) {
_(DROP_ANIMALS).each(function(animal) {
if(pets[animal] > 0 || pets[animal] == -1)
count++
});
}).value();
return count;
}
@@ -22,7 +22,7 @@ function dropPetsCurrentlyOwned(pets) {
_(DROP_ANIMALS).each(function(animal) {
if(pets[animal] > 0)
count++
});
}).value();
return count;
}
@@ -32,7 +32,7 @@ function mountMasterProgress(mounts) {
_(DROP_ANIMALS).each(function(animal) {
if (mounts[animal])
count++
});
}).value();
return count;
}

View File

@@ -1,6 +1,4 @@
import {each, defaults, assign} from 'lodash';
import capitalize from 'lodash.capitalize';
import camelCase from 'lodash.camelcase';
import {each, defaults, assign, capitalize, camelCase} from 'lodash';
import i18n from '../i18n';

View File

@@ -51,9 +51,7 @@
"in-app-purchase": "^0.2.0",
"jade": "~1.11.0",
"js2xmlparser": "~0.1.2",
"lodash": "~2.4.1",
"lodash.camelcase": "^3.0.1",
"lodash.capitalize": "^3.0.0",
"lodash": "^3.10.1",
"loggly": "~1.0.8",
"marked": "^0.3.5",
"merge-stream": "^1.0.0",

View File

@@ -89,7 +89,7 @@ gulp.task('transifex:malformedStrings', () => {
}
});
});
});
}).value();
if (!_.isEmpty(stringsWithMalformedInterpolations)) {
let message = 'The following strings have malformed or missing interpolations';
@@ -128,7 +128,7 @@ function eachTranslationFile(languages, cb) {
cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile)
});
});
}).value();
}
function eachTranslationString(languages, cb) {
@@ -162,7 +162,7 @@ function getStringsWith(json, interpolationRegex) {
var match = value.match(interpolationRegex);
if(match) strings[file_name][key] = match;
});
});
}).value();
return strings;
}

View File

@@ -41,6 +41,7 @@ describe "Coupons", ->
expect(coupons.length).to.equal 10
_(coupons).each (c)->
expect(c.event).to.equal 'wondercon'
.value()
done()
context "while regular user", ->
@@ -73,7 +74,9 @@ describe "Coupons", ->
codes = res.text
expect(codes).to.contain('code')
# Expect each coupon code _id to exist in response
_(coupons).each (c) -> expect(codes).to.contain(c._id)
_(coupons).each (c) ->
expect(codes).to.contain(c._id)
.value()
done()
@@ -89,9 +92,13 @@ describe "Coupons", ->
secondHalf = sortedCoupons[5..9]
# First five coupons should be present in codes
_(firstHalf).each (c) -> expect(codes).to.contain(c._id)
_(firstHalf).each (c) ->
expect(codes).to.contain(c._id)
.value()
# Second five coupons should not be present in codes
_(secondHalf).each (c) -> expect(codes).to.not.contain(c._id)
_(secondHalf).each (c) ->
expect(codes).to.not.contain(c._id)
.value()
done()
it "gets last 5 coupons out of 10 when a limit of 5 is set", (done) ->
@@ -106,9 +113,13 @@ describe "Coupons", ->
secondHalf = sortedCoupons[5..9]
# First five coupons should not be present in codes
_(firstHalf).each (c) -> expect(codes).to.not.contain(c._id)
_(firstHalf).each (c) ->
expect(codes).to.not.contain(c._id)
.value()
# Second five coupons should be present in codes
_(secondHalf).each (c) -> expect(codes).to.contain(c._id)
_(secondHalf).each (c) ->
expect(codes).to.contain(c._id)
.value()
done()
context "while regular user", ->
@@ -142,6 +153,7 @@ describe "Coupons", ->
expect(gear[i]).to.exist
else
expect(gear[i]).to.not.exist
.value()
beforeEach (done) ->
registerNewUser ->

View File

@@ -134,8 +134,8 @@ describe('user.fns.buy', function() {
_(shared.content.gear.tree[type].armoire).each(function(gearObject, gearName) {
var armoireKey = gearObject.key;
fullArmoire[armoireKey] = true;
});
});
}).value();
}).value();
beforeEach(function() {
user.achievements.ultimateGearSets = { rogue: true };

View File

@@ -81,7 +81,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
_(clonedTasks).each(function(val, type) {
challenge[type + 's'].forEach(_cloneTaskAndPush);
});
}).value();
$scope.obj = $scope.newChallenge = new Challenges.Challenge({
name: challenge.name,

View File

@@ -209,7 +209,7 @@ function($rootScope, User, $timeout, $state, Analytics) {
}
User.set(ups);
}
})
}).value();
});
var tour = {};

View File

@@ -48,7 +48,7 @@
total += equipmentStat;
}
});
}).value();
return total;
}

View File

@@ -36,7 +36,7 @@
_(cleansedTask.checklist).forEach(function(item) {
item.completed = false;
item.id = Shared.uuid();
});
}).value();
if (cleansedTask.type !== 'reward') {
delete cleansedTask.value;

View File

@@ -60,7 +60,7 @@ exports.createSubscription = function(data, cb) {
}).defaults({ // allow non-override if a plan was previously used
dateCreated: new Date(),
mysteryItems: []
});
}).value();
}
// Block sub perks

View File

@@ -60,7 +60,7 @@ function _generateLabelForGoogleAnalytics(data) {
label = data[key];
return false; // exit _.each early
}
});
}).value();
return label;
}
@@ -74,7 +74,7 @@ function _generateValueForGoogleAnalytics(data) {
value = data[key];
return false; // exit _.each early
}
});
}).value();
return value;
}

View File

@@ -4,7 +4,7 @@ mixin gemCost(cost)
= ' ' + env.t('locked')
block
-var gearGroup = function(grouping) { return env._(env.Content.gear.flat).where({gearSet:grouping}).pluck('key') }
-var gearGroup = function(grouping) { return env._(env.Content.gear.flat).where({gearSet:grouping}).pluck('key').value() }
-var showPath = function(path, items, joiner) { return path+'["'+items.join('"] '+joiner+' '+path+'["')+'"]'; }
-var unlockPath = function(path, items) { return 'unlock("'+path+'.'+items.join(','+path+'.')+'")'; }