Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lodash to lodash-es #115

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strange-mirrors-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"votes": major
---

Update `lodash` to `lodash-es`. Change the package to be ESM by default.
7 changes: 4 additions & 3 deletions votes/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "votes",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.mjs",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
},
"version": "2.2.2",
Expand Down Expand Up @@ -63,7 +64,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'

Check failure on line 1 in votes/src/classes/method.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/classes/method.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/classes/random-matrix-method.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/classes/random-matrix-method.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/baldwin/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/baldwin/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/biggest-support/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/biggest-support/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/bottom-two-runoff/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/bottom-two-runoff/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/coombs/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/coombs/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/copeland/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/copeland/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/kemeny/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/kemeny/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/majority-judgment/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/majority-judgment/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/maximal-lotteries/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/maximal-lotteries/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/minimax-td/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/minimax-td/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/nanson/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/nanson/index.ts#L1

Unable to resolve path to module 'lodash-es'.

import { RoundBallotMethod } from '../../classes/round-ballot-method'
import type { Ballot, ScoreObject } from '../../types'
Expand All @@ -16,7 +15,7 @@
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'

Check failure on line 1 in votes/src/methods/random-candidates/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/random-candidates/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/ranked-pairs/generate-acyclic-graph.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/ranked-pairs/generate-acyclic-graph.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/ranked-pairs/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/ranked-pairs/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/schulze/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/schulze/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/methods/two-round-runoff/index.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/methods/two-round-runoff/index.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/test/matrix.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/test/matrix.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/test/test-utils.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/test/test-utils.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/utils/condorcet.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/utils/condorcet.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/utils/make-matrix.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/utils/make-matrix.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/utils/normalize.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/utils/normalize.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/utils/scores-zero.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/utils/scores-zero.ts#L1

Unable to resolve path to module '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'

Check failure on line 1 in votes/src/utils/scores.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

votes/src/utils/scores.ts#L1

Unable to resolve path to module 'lodash-es'.

export const scoresToRanking = (scores: {
[candidate: string]: number
Expand Down
Loading
Loading