Skip to content

Commit

Permalink
use find instead of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjae-lee committed Nov 12, 2020
1 parent 1d3c977 commit fa7ea26
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/middlewares/createInsightsMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export const createInsightsMiddleware: CreateInsightsMiddleware = props => {
// At this point, even though `search-insights` is not loaded yet,
// we still want to read the token from the queue.
// Otherwise, the first search call will be fired without the token.
(insightsClient as any).queue.forEach(([method, firstArgument]) => {
if (method === 'setUserToken') {
queuedUserToken = firstArgument;
}
});
[, queuedUserToken] =
(insightsClient as any).queue
.slice()
.reverse()
.find(([method]) => method === 'setUserToken') || [];
}
insightsClient('_get', '_userToken', (userToken: string) => {
// If user has called `aa('setUserToken', 'my-user-token')` before creating
Expand Down

0 comments on commit fa7ea26

Please sign in to comment.