Skip to content

Commit

Permalink
Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 19, 2021
1 parent 0ca22e1 commit 087fb94
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/history/delta/formats/commit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findIndexReverse } from '../../../utils/find.js'
import { findLastIndex } from '../../../utils/find.js'

import { findByGitRef } from './git.js'

Expand All @@ -18,7 +18,7 @@ const GIT_COMMIT_REGEXP = /^[\da-f]{7,}$/iu
// users most likely want.
// When none is found in `rawResult.systems`, we try to use `git` instead.
const findByCommit = async function (rawResults, commit, cwd) {
const index = findIndexReverse(rawResults, ({ systems: [{ git = {} }] }) =>
const index = findLastIndex(rawResults, ({ systems: [{ git = {} }] }) =>
git.commit.startsWith(commit),
)

Expand Down
4 changes: 2 additions & 2 deletions src/history/delta/formats/tag.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findIndexReverse } from '../../../utils/find.js'
import { findLastIndex } from '../../../utils/find.js'

import { findByGitRef } from './git.js'

Expand All @@ -15,7 +15,7 @@ const parseTag = function (delta) {
// users most likely want.
// When none is found in `rawResult.systems`, we try to use `git` instead.
const findByTag = async function (rawResults, tagOrBranch, cwd) {
const index = findIndexReverse(
const index = findLastIndex(
rawResults,
({ systems: [{ git: { tag, branch } = {} }] }) =>
tag === tagOrBranch || branch === tagOrBranch,
Expand Down
4 changes: 2 additions & 2 deletions src/run/logs/normalize.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import stripFinalNewline from 'strip-final-newline'

import { findIndexReverse } from '../../utils/find.js'
import { findLastIndex } from '../../utils/find.js'

// Normalize task logs
export const normalizeLogs = function (taskLogs, truncated) {
Expand Down Expand Up @@ -36,7 +36,7 @@ const stripPartialLine = function (taskLogs, truncated) {
// Duplicate lines are very likely since the task is repeated.
const removeDuplicateLines = function (taskLogs) {
const lines = taskLogs.split('\n')
const duplicateIndex = findIndexReverse(lines, isDuplicateLine)
const duplicateIndex = findLastIndex(lines, isDuplicateLine)

if (duplicateIndex === -1) {
return taskLogs
Expand Down
4 changes: 2 additions & 2 deletions src/select/match.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCombinationIds } from '../combination/ids/get.js'
import { findIndexReverse } from '../utils/find.js'
import { findLastIndex } from '../utils/find.js'

// Select combinations according to the `select|limit` configuration properties.
// Each selector:
Expand Down Expand Up @@ -34,7 +34,7 @@ export const matchSelectors = function (combination, selectors) {
const combinationIds = getCombinationIds(combination).map(
normalizeCombinationId,
)
const index = findIndexReverse(selectors, (selector) =>
const index = findLastIndex(selectors, (selector) =>
matchIds(combinationIds, selector),
)

Expand Down
2 changes: 1 addition & 1 deletion src/utils/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const findLast = function (array, testFunc) {
// TODO: replace with `Array.findLastIndex()` once this is supported by all
// supported Node.js versions.
// Use imperative code for performance.
export const findIndexReverse = function (array, testFunc) {
export const findLastIndex = function (array, testFunc) {
// eslint-disable-next-line fp/no-loops, fp/no-let, fp/no-mutation
for (let index = array.length - 1; index >= 0; index -= 1) {
// eslint-disable-next-line max-depth
Expand Down

0 comments on commit 087fb94

Please sign in to comment.