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 = "