Skip to content

Commit

Permalink
chore: change lodash to lodash-es
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Imports of `lodash` are now `lodash-es`

re #107
  • Loading branch information
lzear committed Feb 27, 2024
1 parent 4e1b432 commit 50b1bdd
Show file tree
Hide file tree
Showing 26 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion votes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"javascript-lp-solver": "0.4.15",
"lodash": "^4.17.21"
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"javascript-lp-solver": ">=0.4.0"
Expand Down
2 changes: 1 addition & 1 deletion votes/src/classes/method.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import { scoresToRanking } from '../utils/scores'

Expand Down
2 changes: 1 addition & 1 deletion votes/src/classes/random-matrix-method.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import type { Matrix, ScoreObject } from '../types'
import { shuffleArray } from '../utils/shuffle-array'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/baldwin/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import { RoundBallotMethod } from '../../classes/round-ballot-method'
import type { Ballot, ScoreObject } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/biggest-support/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import { BallotMethod } from '../../classes/ballot-method'
import type { Ballot } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/bottom-two-runoff/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import { RoundBallotMethod } from '../../classes/round-ballot-method'
import type { Ballot, ScoreObject } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/coombs/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import { RoundBallotMethod } from '../../classes/round-ballot-method'
import type { Ballot, ScoreObject } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/copeland/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import { MatrixScoreMethod } from '../../classes/matrix-score-method'
import type { Matrix, ScoreObject } from '../../types'
Expand Down
3 changes: 1 addition & 2 deletions votes/src/methods/kemeny/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import range from 'lodash/range'
import zipObject from 'lodash/zipObject'
import { range, zipObject } from 'lodash-es'

import { MatrixScoreMethod } from '../../classes/matrix-score-method'
import type { Matrix, ScoreObject } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/majority-judgment/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import { BallotMethod } from '../../classes/ballot-method'
import type { Ballot, ScoreObject } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/maximal-lotteries/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import zipObject from 'lodash/zipObject'
import { zipObject } from 'lodash-es'

import { RandomMatrixMethod } from '../../classes/random-matrix-method'
import { findNashEquilibrium } from '../../simplex/find-nash-equilibrium'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/minimax-td/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import type { Matrix, ScoreObject } from '../../types'
import { findSmithSet } from '../../utils/condorcet'
Expand Down
5 changes: 2 additions & 3 deletions votes/src/methods/nanson/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash'
import sum from 'lodash/sum'
import _ from 'lodash-es'

import { RoundBallotMethod } from '../../classes/round-ballot-method'
import type { Ballot, ScoreObject } from '../../types'
Expand All @@ -16,7 +15,7 @@ const round = (
const borda = new Borda({ candidates, ballots })
const bordaScores = borda.scores()
const scores = Object.values(bordaScores)
const avg = sum(scores) / scores.length
const avg = _.sum(scores) / scores.length
const eliminated = candidates.filter((c) => bordaScores[c] <= avg)
const qualified = _.difference(candidates, eliminated)
return { eliminated, qualified, scores: bordaScores }
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/random-candidates/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import zipObject from 'lodash/zipObject'
import { zipObject } from 'lodash-es'

import { RandomMethod } from '../../classes/random-method'
import type { ScoreObject } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/ranked-pairs/generate-acyclic-graph.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import { Tarjan } from './tarjan'
import { Vertex } from './vertex'
Expand Down
4 changes: 1 addition & 3 deletions votes/src/methods/ranked-pairs/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import groupBy from 'lodash/groupBy'
import range from 'lodash/range'
import zipObject from 'lodash/zipObject'
import { groupBy, range, zipObject } from 'lodash-es'

import { MatrixScoreMethod } from '../../classes/matrix-score-method'
import type { Matrix, ScoreObject } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/schulze/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import range from 'lodash/range'
import { range } from 'lodash-es'

import { MatrixScoreMethod } from '../../classes/matrix-score-method'
import type { Matrix, ScoreObject } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/methods/two-round-runoff/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import { RoundBallotMethod } from '../../classes/round-ballot-method'
import type { ScoreObject } from '../../types'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/test/matrix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import range from 'lodash/range'
import { range } from 'lodash-es'

export const product = (a: number[][], b: number[][]): number[][] => {
const dimA = [a.length, a[0].length]
Expand Down
2 changes: 1 addition & 1 deletion votes/src/test/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fill from 'lodash/fill'
import { fill } from 'lodash-es'

import type { Ballot } from '../types'
import { toWeightedBallots } from '../utils'
Expand Down
2 changes: 1 addition & 1 deletion votes/src/utils/condorcet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import type { Matrix } from '../types'

Expand Down
4 changes: 1 addition & 3 deletions votes/src/utils/make-matrix.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import difference from 'lodash/difference'
import range from 'lodash/range'
import times from 'lodash/times'
import { difference, range, times } from 'lodash-es'

import type { Ballot, Matrix } from '../types'

Expand Down
2 changes: 1 addition & 1 deletion votes/src/utils/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import _ from 'lodash-es'

import type { Ballot } from '../types'

Expand Down
2 changes: 1 addition & 1 deletion votes/src/utils/scores-zero.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import zipObject from 'lodash/zipObject'
import { zipObject } from 'lodash-es'

import type { ScoreObject } from '../types'

Expand Down
4 changes: 1 addition & 3 deletions votes/src/utils/scores.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import groupBy from 'lodash/groupBy'
import sortBy from 'lodash/sortBy'
import toPairs from 'lodash/toPairs'
import { groupBy, sortBy, toPairs } from 'lodash-es'

export const scoresToRanking = (scores: {
[candidate: string]: number
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9058,6 +9058,11 @@ locate-path@^6.0.0:
dependencies:
p-locate "^5.0.0"

lodash-es@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee"
integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==

lodash.camelcase@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
Expand Down

0 comments on commit 50b1bdd

Please sign in to comment.