diff --git a/common/script/count.js b/common/script/count.js index 6305646836..478265931a 100644 --- a/common/script/count.js +++ b/common/script/count.js @@ -9,7 +9,7 @@ function beastMasterProgress (pets) { _(DROP_ANIMALS).each((animal) => { if (pets[animal] > 0 || pets[animal] === -1) count++; - }); + }).value(); return count; } @@ -20,7 +20,7 @@ function dropPetsCurrentlyOwned (pets) { _(DROP_ANIMALS).each((animal) => { if (pets[animal] > 0) count++; - }); + }).value(); return count; } @@ -31,7 +31,7 @@ function mountMasterProgress (mounts) { _(DROP_ANIMALS).each((animal) => { if (mounts[animal]) count++; - }); + }).value(); return count; } diff --git a/common/script/i18n.js b/common/script/i18n.js index 908925e9e5..41a0e63bc2 100644 --- a/common/script/i18n.js +++ b/common/script/i18n.js @@ -37,7 +37,7 @@ function t (stringName) { if (string) { try { - return _.template(string, clonedVars); + return _.template(string)(clonedVars); } catch (_error) { return 'Error processing the string. Please see Help > Report a Bug.'; } @@ -51,7 +51,7 @@ function t (stringName) { } try { - return _.template(stringNotFound, { + return _.template(stringNotFound)({ string: stringName, }); } catch (_error) { diff --git a/common/script/index.js b/common/script/index.js index f237002c52..2246bc259a 100644 --- a/common/script/index.js +++ b/common/script/index.js @@ -126,7 +126,7 @@ preenHistory = function(history) { */ api.preenTodos = function(tasks) { - return _.where(tasks, function(t) { + return _.filter(tasks, function(t) { return !t.completed || (t.challenge && t.challenge.id) || moment(t.dateCompleted).isAfter(moment().subtract({ days: 3 })); diff --git a/common/script/src/i18n.js b/common/script/src/i18n.js index 315624e76a..3b91ede35b 100644 --- a/common/script/src/i18n.js +++ b/common/script/src/i18n.js @@ -25,7 +25,7 @@ module.exports = { clonedVars.locale = locale; if (string) { try { - return _.template(string, clonedVars); + return _.template(string)(clonedVars); } catch (_error) { e = _error; return 'Error processing the string. Please see Help > Report a Bug.'; @@ -37,7 +37,7 @@ module.exports = { stringNotFound = module.exports.translations[locale] && module.exports.translations[locale].stringNotFound; } try { - return _.template(stringNotFound, { + return _.template(stringNotFound)({ string: stringName }); } catch (_error) { diff --git a/package.json b/package.json index b19c0ee078..8bb96f2d7c 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "in-app-purchase": "^0.2.0", "jade": "~1.11.0", "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", diff --git a/tasks/gulp-transifex-test.js b/tasks/gulp-transifex-test.js index d4e6cdc3c3..6326069815 100644 --- a/tasks/gulp-transifex-test.js +++ b/tasks/gulp-transifex-test.js @@ -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; } diff --git a/test/api-legacy/coupons.js b/test/api-legacy/coupons.js index af315c549c..1f4fcda3b6 100644 --- a/test/api-legacy/coupons.js +++ b/test/api-legacy/coupons.js @@ -54,7 +54,7 @@ describe("Coupons", function() { expect(coupons.length).to.equal(10); _(coupons).each(function(c) { return expect(c.event).to.equal('wondercon'); - }); + }).value(); return done(); }); }); @@ -90,7 +90,7 @@ describe("Coupons", function() { expect(codes).to.contain('code'); _(coupons).each(function(c) { return expect(codes).to.contain(c._id); - }); + }).value(); return done(); }); }); @@ -106,10 +106,10 @@ describe("Coupons", function() { secondHalf = sortedCoupons.slice(5, 10); _(firstHalf).each(function(c) { return expect(codes).to.contain(c._id); - }); + }).value(); _(secondHalf).each(function(c) { return expect(codes).to.not.contain(c._id); - }); + }).value(); return done(); }); }); @@ -125,10 +125,10 @@ describe("Coupons", function() { secondHalf = sortedCoupons.slice(5, 10); _(firstHalf).each(function(c) { return expect(codes).to.not.contain(c._id); - }); + }).value(); _(secondHalf).each(function(c) { return expect(codes).to.contain(c._id); - }); + }).value(); return done(); }); }); @@ -159,7 +159,7 @@ describe("Coupons", function() { } else { return expect(gear[i]).to.not.exist; } - }); + }).value(); }; beforeEach(function(done) { return registerNewUser(function() { diff --git a/test/common/user.fns.buy.test.js b/test/common/user.fns.buy.test.js index a4b067f9f4..0cf39c1eb0 100644 --- a/test/common/user.fns.buy.test.js +++ b/test/common/user.fns.buy.test.js @@ -160,8 +160,8 @@ describe('user.fns.buy', () => { let armoireKey = gearObject.key; fullArmoire[armoireKey] = true; - }); - }); + }).value(); + }).value(); beforeEach(() => { user.achievements.ultimateGearSets = { rogue: true }; diff --git a/website/public/js/controllers/challengesCtrl.js b/website/public/js/controllers/challengesCtrl.js index 9152857195..30aac589d5 100644 --- a/website/public/js/controllers/challengesCtrl.js +++ b/website/public/js/controllers/challengesCtrl.js @@ -83,7 +83,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, diff --git a/website/public/js/services/guideServices.js b/website/public/js/services/guideServices.js index 86c2c36cc7..a8bd144e52 100644 --- a/website/public/js/services/guideServices.js +++ b/website/public/js/services/guideServices.js @@ -184,7 +184,7 @@ function($rootScope, User, $timeout, $state, Analytics) { } _.each(chapters, function(chapter, k){ - _(chapter).flatten().each(function(step, i) { + _(chapter).flattenDeep().each(function(step, i) { step.content = "
" + step.content + "
"; $(step.element).popover('destroy'); // destroy existing hover popovers so we can add our own step.onShow = function(){ @@ -209,7 +209,7 @@ function($rootScope, User, $timeout, $state, Analytics) { } User.set(ups); } - }) + }).value(); }); var tour = {}; @@ -226,7 +226,7 @@ function($rootScope, User, $timeout, $state, Analytics) { '

' + '
' + '
' + - (showCounter ? ''+ (i+1 +' of '+ _.flatten(chapters[k]).length) +'' : '')+ // counter + (showCounter ? ''+ (i+1 +' of '+ _.flattenDeep(chapters[k]).length) +'' : '')+ // counter '
' + (step.hideNavigation ? '' : '') + (showFinish ? ('') : diff --git a/website/public/js/services/statServices.js b/website/public/js/services/statServices.js index e836b39fb2..f2db805fb6 100644 --- a/website/public/js/services/statServices.js +++ b/website/public/js/services/statServices.js @@ -48,7 +48,7 @@ total += equipmentStat; } - }); + }).value(); return total; } diff --git a/website/public/js/services/taskServices.js b/website/public/js/services/taskServices.js index 3f968dfa6e..bbe7f6f689 100644 --- a/website/public/js/services/taskServices.js +++ b/website/public/js/services/taskServices.js @@ -36,7 +36,7 @@ _(cleansedTask.checklist).forEach(function(item) { item.completed = false; item.id = Shared.uuid(); - }); + }).value(); if (cleansedTask.type !== 'reward') { delete cleansedTask.value; diff --git a/website/src/controllers/payments/index.js b/website/src/controllers/payments/index.js index 465fb31d01..866c33381b 100644 --- a/website/src/controllers/payments/index.js +++ b/website/src/controllers/payments/index.js @@ -59,7 +59,7 @@ exports.createSubscription = function(data, cb) { }).defaults({ // allow non-override if a plan was previously used dateCreated: new Date(), mysteryItems: [] - }); + }).value(); } // Block sub perks diff --git a/website/src/libs/analytics.js b/website/src/libs/analytics.js index 442c4b9b5c..dffa7c2a9b 100644 --- a/website/src/libs/analytics.js +++ b/website/src/libs/analytics.js @@ -59,7 +59,7 @@ function _generateLabelForGoogleAnalytics(data) { label = data[key]; return false; // exit _.each early } - }); + }).value(); return label; } @@ -73,7 +73,7 @@ function _generateValueForGoogleAnalytics(data) { value = data[key]; return false; // exit _.each early } - }); + }).value(); return value; } diff --git a/website/views/options/profile.jade b/website/views/options/profile.jade index 8c4b437df8..68b78c5a12 100644 --- a/website/views/options/profile.jade +++ b/website/views/options/profile.jade @@ -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+'.')+'")'; }