From 74ea773c25e814f78387838d2a2773c0716dfb33 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Tue, 17 Apr 2018 21:47:39 -0700 Subject: [PATCH] remove lodash forEach to reduce bundle size (#156) --- routes/_actions/deleteStatuses.js | 4 ++-- routes/_database/databaseLifecycle.js | 6 ++---- webpack.client.config.js | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/routes/_actions/deleteStatuses.js b/routes/_actions/deleteStatuses.js index 72bdcf9..cff6bd6 100644 --- a/routes/_actions/deleteStatuses.js +++ b/routes/_actions/deleteStatuses.js @@ -1,7 +1,6 @@ import { getIdsThatRebloggedThisStatus, getNotificationIdsForStatuses } from './statuses' import { store } from '../_store/store' import { scheduleIdleTask } from '../_utils/scheduleIdleTask' -import forEach from 'lodash-es/forEach' import isEqual from 'lodash-es/isEqual' import { deleteStatusesAndNotifications as deleteStatusesAndNotificationsFromDatabase @@ -12,7 +11,8 @@ function filterItemIdsFromTimelines (instanceName, timelineFilter, idFilter) { keys.forEach(key => { let timelineData = store.getAllTimelineData(instanceName, key) - forEach(timelineData, (ids, timelineName) => { + Object.keys(timelineData).forEach(timelineName => { + let ids = timelineData[timelineName] if (!timelineFilter(timelineName)) { return } diff --git a/routes/_database/databaseLifecycle.js b/routes/_database/databaseLifecycle.js index f10ac84..c1c46da 100644 --- a/routes/_database/databaseLifecycle.js +++ b/routes/_database/databaseLifecycle.js @@ -14,8 +14,6 @@ import { USERNAME_LOWERCASE } from './constants' -import forEach from 'lodash-es/forEach' - const openReqs = {} const databaseCache = {} @@ -47,8 +45,8 @@ export function getDatabase (instanceName) { ? db.createObjectStore(name, init) : db.createObjectStore(name) if (indexes) { - forEach(indexes, (indexValue, indexKey) => { - store.createIndex(indexKey, indexValue) + Object.keys(indexes).forEach(indexKey => { + store.createIndex(indexKey, indexes[indexKey]) }) } } diff --git a/webpack.client.config.js b/webpack.client.config.js index ae5cbb0..5cfe79f 100644 --- a/webpack.client.config.js +++ b/webpack.client.config.js @@ -69,7 +69,6 @@ module.exports = { }, plugins: [ new LodashModuleReplacementPlugin({ - collections: true, caching: true }) ].concat(isDev ? [