mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
wip: starts upgrading lodash to v3
This commit is contained in:
@@ -11,7 +11,7 @@ function beastMasterProgress(pets) {
|
|||||||
_(DROP_ANIMALS).each(function(animal) {
|
_(DROP_ANIMALS).each(function(animal) {
|
||||||
if(pets[animal] > 0 || pets[animal] == -1)
|
if(pets[animal] > 0 || pets[animal] == -1)
|
||||||
count++
|
count++
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ function dropPetsCurrentlyOwned(pets) {
|
|||||||
_(DROP_ANIMALS).each(function(animal) {
|
_(DROP_ANIMALS).each(function(animal) {
|
||||||
if(pets[animal] > 0)
|
if(pets[animal] > 0)
|
||||||
count++
|
count++
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ function mountMasterProgress(mounts) {
|
|||||||
_(DROP_ANIMALS).each(function(animal) {
|
_(DROP_ANIMALS).each(function(animal) {
|
||||||
if (mounts[animal])
|
if (mounts[animal])
|
||||||
count++
|
count++
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import {each, defaults, assign} from 'lodash';
|
import {each, defaults, assign, capitalize, camelCase} from 'lodash';
|
||||||
import capitalize from 'lodash.capitalize';
|
|
||||||
import camelCase from 'lodash.camelcase';
|
|
||||||
|
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
|
|
||||||
|
|||||||
@@ -51,9 +51,7 @@
|
|||||||
"in-app-purchase": "^0.2.0",
|
"in-app-purchase": "^0.2.0",
|
||||||
"jade": "~1.11.0",
|
"jade": "~1.11.0",
|
||||||
"js2xmlparser": "~0.1.2",
|
"js2xmlparser": "~0.1.2",
|
||||||
"lodash": "~2.4.1",
|
"lodash": "^3.10.1",
|
||||||
"lodash.camelcase": "^3.0.1",
|
|
||||||
"lodash.capitalize": "^3.0.0",
|
|
||||||
"loggly": "~1.0.8",
|
"loggly": "~1.0.8",
|
||||||
"marked": "^0.3.5",
|
"marked": "^0.3.5",
|
||||||
"merge-stream": "^1.0.0",
|
"merge-stream": "^1.0.0",
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ gulp.task('transifex:malformedStrings', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
if (!_.isEmpty(stringsWithMalformedInterpolations)) {
|
if (!_.isEmpty(stringsWithMalformedInterpolations)) {
|
||||||
let message = 'The following strings have malformed or missing interpolations';
|
let message = 'The following strings have malformed or missing interpolations';
|
||||||
@@ -128,7 +128,7 @@ function eachTranslationFile(languages, cb) {
|
|||||||
|
|
||||||
cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile)
|
cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile)
|
||||||
});
|
});
|
||||||
});
|
}).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
function eachTranslationString(languages, cb) {
|
function eachTranslationString(languages, cb) {
|
||||||
@@ -162,7 +162,7 @@ function getStringsWith(json, interpolationRegex) {
|
|||||||
var match = value.match(interpolationRegex);
|
var match = value.match(interpolationRegex);
|
||||||
if(match) strings[file_name][key] = match;
|
if(match) strings[file_name][key] = match;
|
||||||
});
|
});
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ describe "Coupons", ->
|
|||||||
expect(coupons.length).to.equal 10
|
expect(coupons.length).to.equal 10
|
||||||
_(coupons).each (c)->
|
_(coupons).each (c)->
|
||||||
expect(c.event).to.equal 'wondercon'
|
expect(c.event).to.equal 'wondercon'
|
||||||
|
.value()
|
||||||
done()
|
done()
|
||||||
|
|
||||||
context "while regular user", ->
|
context "while regular user", ->
|
||||||
@@ -73,7 +74,9 @@ describe "Coupons", ->
|
|||||||
codes = res.text
|
codes = res.text
|
||||||
expect(codes).to.contain('code')
|
expect(codes).to.contain('code')
|
||||||
# Expect each coupon code _id to exist in response
|
# 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()
|
done()
|
||||||
|
|
||||||
@@ -89,9 +92,13 @@ describe "Coupons", ->
|
|||||||
secondHalf = sortedCoupons[5..9]
|
secondHalf = sortedCoupons[5..9]
|
||||||
|
|
||||||
# First five coupons should be present in codes
|
# 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
|
# 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()
|
done()
|
||||||
|
|
||||||
it "gets last 5 coupons out of 10 when a limit of 5 is set", (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]
|
secondHalf = sortedCoupons[5..9]
|
||||||
|
|
||||||
# First five coupons should not be present in codes
|
# 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
|
# 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()
|
done()
|
||||||
|
|
||||||
context "while regular user", ->
|
context "while regular user", ->
|
||||||
@@ -142,6 +153,7 @@ describe "Coupons", ->
|
|||||||
expect(gear[i]).to.exist
|
expect(gear[i]).to.exist
|
||||||
else
|
else
|
||||||
expect(gear[i]).to.not.exist
|
expect(gear[i]).to.not.exist
|
||||||
|
.value()
|
||||||
|
|
||||||
beforeEach (done) ->
|
beforeEach (done) ->
|
||||||
registerNewUser ->
|
registerNewUser ->
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ describe('user.fns.buy', function() {
|
|||||||
_(shared.content.gear.tree[type].armoire).each(function(gearObject, gearName) {
|
_(shared.content.gear.tree[type].armoire).each(function(gearObject, gearName) {
|
||||||
var armoireKey = gearObject.key;
|
var armoireKey = gearObject.key;
|
||||||
fullArmoire[armoireKey] = true;
|
fullArmoire[armoireKey] = true;
|
||||||
});
|
}).value();
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
user.achievements.ultimateGearSets = { rogue: true };
|
user.achievements.ultimateGearSets = { rogue: true };
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
|||||||
|
|
||||||
_(clonedTasks).each(function(val, type) {
|
_(clonedTasks).each(function(val, type) {
|
||||||
challenge[type + 's'].forEach(_cloneTaskAndPush);
|
challenge[type + 's'].forEach(_cloneTaskAndPush);
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
$scope.obj = $scope.newChallenge = new Challenges.Challenge({
|
$scope.obj = $scope.newChallenge = new Challenges.Challenge({
|
||||||
name: challenge.name,
|
name: challenge.name,
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ function($rootScope, User, $timeout, $state, Analytics) {
|
|||||||
}
|
}
|
||||||
User.set(ups);
|
User.set(ups);
|
||||||
}
|
}
|
||||||
})
|
}).value();
|
||||||
});
|
});
|
||||||
|
|
||||||
var tour = {};
|
var tour = {};
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
total += equipmentStat;
|
total += equipmentStat;
|
||||||
}
|
}
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
_(cleansedTask.checklist).forEach(function(item) {
|
_(cleansedTask.checklist).forEach(function(item) {
|
||||||
item.completed = false;
|
item.completed = false;
|
||||||
item.id = Shared.uuid();
|
item.id = Shared.uuid();
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
if (cleansedTask.type !== 'reward') {
|
if (cleansedTask.type !== 'reward') {
|
||||||
delete cleansedTask.value;
|
delete cleansedTask.value;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ exports.createSubscription = function(data, cb) {
|
|||||||
}).defaults({ // allow non-override if a plan was previously used
|
}).defaults({ // allow non-override if a plan was previously used
|
||||||
dateCreated: new Date(),
|
dateCreated: new Date(),
|
||||||
mysteryItems: []
|
mysteryItems: []
|
||||||
});
|
}).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block sub perks
|
// Block sub perks
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ function _generateLabelForGoogleAnalytics(data) {
|
|||||||
label = data[key];
|
label = data[key];
|
||||||
return false; // exit _.each early
|
return false; // exit _.each early
|
||||||
}
|
}
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ function _generateValueForGoogleAnalytics(data) {
|
|||||||
value = data[key];
|
value = data[key];
|
||||||
return false; // exit _.each early
|
return false; // exit _.each early
|
||||||
}
|
}
|
||||||
});
|
}).value();
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ mixin gemCost(cost)
|
|||||||
= ' ' + env.t('locked')
|
= ' ' + env.t('locked')
|
||||||
block
|
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 showPath = function(path, items, joiner) { return path+'["'+items.join('"] '+joiner+' '+path+'["')+'"]'; }
|
||||||
-var unlockPath = function(path, items) { return 'unlock("'+path+'.'+items.join(','+path+'.')+'")'; }
|
-var unlockPath = function(path, items) { return 'unlock("'+path+'.'+items.join(','+path+'.')+'")'; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user