Skip to content

Commit

Permalink
fix: use lodash-es
Browse files Browse the repository at this point in the history
  • Loading branch information
lzear committed Jan 13, 2021
1 parent c1cafcf commit f4e03f8
Show file tree
Hide file tree
Showing 18 changed files with 107 additions and 63 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@types/jest": "^26.0.20",
"@types/lodash": "^4.14.167",
"@types/lodash-es": "^4.17.4",
"@types/node": "^14.14.20",
"@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.13.0",
Expand All @@ -73,16 +73,16 @@
"rollup-plugin-sizes": "^1.0.3",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.29.0",
"semantic-release": "^17.3.1",
"semantic-release": "^17.3.2",
"shelljs": "^0.8.4",
"travis-deploy-once": "^5.0.11",
"ts-jest": "^26.4.4",
"ts-node": "^9.1.1",
"typedoc": "^0.19.2",
"typedoc": "^0.20.14",
"typescript": "^4.1.3"
},
"dependencies": {
"lodash": "^4.17.20"
"lodash-es": "^4.17.20"
},
"bugs": {
"url": "https://github.com/lzear/votes/issues"
Expand Down
2 changes: 1 addition & 1 deletion src/methods/baldwin/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import difference from 'lodash/difference'
import difference from 'lodash-es/difference'
import {
SystemUsingRankings,
ScoreObject,
Expand Down
2 changes: 1 addition & 1 deletion src/methods/coombs/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import difference from 'lodash/difference'
import difference from 'lodash-es/difference'
import {
SystemUsingRankings,
ScoreObject,
Expand Down
4 changes: 2 additions & 2 deletions src/methods/copeland/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-plusplus */
import range from 'lodash/range'
import zipObject from 'lodash/zipObject'
import range from 'lodash-es/range'
import zipObject from 'lodash-es/zipObject'
import {
SystemUsingMatrix,
VotingSystem,
Expand Down
4 changes: 2 additions & 2 deletions src/methods/kemeny/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import zipObject from 'lodash/zipObject'
import range from 'lodash/range'
import zipObject from 'lodash-es/zipObject'
import range from 'lodash-es/range'
import {
SystemUsingMatrix,
VotingSystem,
Expand Down
2 changes: 1 addition & 1 deletion 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/zipObject'
import { solve } from '../../simplex'
import {
SystemUsingMatrix,
Expand Down
4 changes: 2 additions & 2 deletions src/methods/nanson/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sum from 'lodash/sum'
import difference from 'lodash/difference'
import sum from 'lodash-es/sum'
import difference from 'lodash-es/difference'
import {
SystemUsingRankings,
ScoreObject,
Expand Down
8 changes: 4 additions & 4 deletions src/methods/ranked-pairs/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import groupBy from 'lodash/groupBy'
import range from 'lodash/range'
import uniq from 'lodash/uniq'
import zipObject from 'lodash/zipObject'
import groupBy from 'lodash-es/groupBy'
import range from 'lodash-es/range'
import uniq from 'lodash-es/uniq'
import zipObject from 'lodash-es/zipObject'
import {
Matrix,
ScoreObject,
Expand Down
2 changes: 1 addition & 1 deletion src/methods/schulze/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-plusplus */
import range from 'lodash/range'
import range from 'lodash-es/range'
import {
SystemUsingMatrix,
VotingSystem,
Expand Down
2 changes: 1 addition & 1 deletion 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/range'

export const product = (a: number[][], b: number[][]): number[][] => {
const dimA = [a.length, a[0].length]
Expand Down
8 changes: 4 additions & 4 deletions src/test/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fill from 'lodash/fill'
import random from 'lodash/random'
import range from 'lodash/range'
import shuffle from 'lodash/shuffle'
import fill from 'lodash-es/fill'
import random from 'lodash-es/random'
import range from 'lodash-es/range'
import shuffle from 'lodash-es/shuffle'
import { Ballot } from '../types'
import { toWeightedBallots } from '../utils'

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

export const findCondorcet = ({ candidates, array }: Matrix): Matrix => {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/makeMatrix.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import difference from 'lodash/difference'
import range from 'lodash/range'
import times from 'lodash/times'
import difference from 'lodash-es/difference'
import range from 'lodash-es/range'
import times from 'lodash-es/times'
import { Matrix, Ballot } from '../types'

export const matrixFromBallots = (
Expand Down
12 changes: 6 additions & 6 deletions src/utils/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import difference from 'lodash/difference'
import every from 'lodash/every'
import flatten from 'lodash/flatten'
import intersection from 'lodash/intersection'
import isEqual from 'lodash/isEqual'
import uniq from 'lodash/uniq'
import difference from 'lodash-es/difference'
import every from 'lodash-es/every'
import flatten from 'lodash-es/flatten'
import intersection from 'lodash-es/intersection'
import isEqual from 'lodash-es/isEqual'
import uniq from 'lodash-es/uniq'

import { Ballot } from '../types'

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

export const scoresToRanking = (scores: {
[candidate: string]: number
Expand Down
2 changes: 1 addition & 1 deletion src/utils/scoresZero.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/zipObject'
import { ScoreObject } from '../types'

export const scoresZero = (candidates: string[]): ScoreObject =>
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es5",
"target": "esnext",
"module": "es2015",
"lib": ["es7", "es2015", "es2016", "es2017", "es2019", "esnext", "dom"],
"strict": true,
Expand Down
94 changes: 69 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,14 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0"
integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==

"@types/lodash@^4.14.167":
"@types/lodash-es@^4.17.4":
version "4.17.4"
resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.4.tgz#b2e440d2bf8a93584a9fd798452ec497986c9b97"
integrity sha512-BBz79DCJbD2CVYZH67MBeHZRX++HF+5p8Mo5MzjZi64Wac39S3diedJYHZtScbRVf4DjZyN6LzA0SB0zy+HSSQ==
dependencies:
"@types/lodash" "*"

"@types/lodash@*":
version "4.14.167"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.167.tgz#ce7d78553e3c886d4ea643c37ec7edc20f16765e"
integrity sha512-w7tQPjARrvdeBkX/Rwg95S592JwxqOjmms3zWQ0XZgSyxSLdzWaYH3vErBhdVS/lRBX7F8aBYcYJYTr5TMGOzw==
Expand Down Expand Up @@ -2584,7 +2591,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
integrity sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=

colors@^1.1.2:
colors@^1.1.2, colors@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78"
integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==
Expand Down Expand Up @@ -4268,11 +4275,6 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"

highlight.js@^10.2.0:
version "10.5.0"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.5.0.tgz#3f09fede6a865757378f2d9ebdcbc15ba268f98f"
integrity sha512-xTmvd9HiIHR6L53TMC7TKolEj65zG1XU+Onr8oi86mYa+nLcIbxTTWkpW7CsEwv/vK7u1zb8alZIMLDqqN6KTw==

homedir-polyfill@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8"
Expand Down Expand Up @@ -5415,7 +5417,7 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1:
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=

[email protected], json5@^2.1.2:
[email protected], json5@^2.1.0, json5@^2.1.2:
version "2.1.3"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43"
integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==
Expand Down Expand Up @@ -5776,6 +5778,11 @@ lockfile@^1.0.4:
dependencies:
signal-exit "^3.0.2"

lodash-es@^4.17.20:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.20.tgz#29f6332eefc60e849f869c264bc71126ad61e8f7"
integrity sha512-JD1COMZsq8maT6mnuz1UMV0jvYD0E0aUsSOdrr1/nAG3dhqQXwRRgeW0cSqH1U43INKcqxaiVIQNOUDld7gRDA==

lodash._baseuniq@~4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
Expand Down Expand Up @@ -6057,7 +6064,7 @@ marked@^1.0.0:
resolved "https://registry.yarnpkg.com/marked/-/marked-1.2.2.tgz#5d77ffb789c4cb0ae828bfe76250f7140b123f70"
integrity sha512-5jjKHVl/FPo0Z6ocP3zYhKiJLzkwJAw4CZoLjv57FkvbUuwOX4LIBBGGcXjAY6ATcd1q9B8UTj5T9Umauj0QYQ==

marked@^1.1.1:
marked@^1.2.5:
version "1.2.7"
resolved "https://registry.yarnpkg.com/marked/-/marked-1.2.7.tgz#6e14b595581d2319cdcf033a24caaf41455a01fb"
integrity sha512-No11hFYcXr/zkBvL6qFmAp1z6BKY3zqLMHny/JN/ey+al7qwCM2+CMBL9BOgqMxZU36fz4cCWfn2poWIf7QRXA==
Expand Down Expand Up @@ -6778,6 +6785,13 @@ onetime@^5.1.0:
dependencies:
mimic-fn "^2.1.0"

onigasm@^2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/onigasm/-/onigasm-2.2.5.tgz#cc4d2a79a0fa0b64caec1f4c7ea367585a676892"
integrity sha512-F+th54mPc0l1lp1ZcFMyL/jTs2Tlq4SqIHKIXGZOR/VkHkF9A7Fr5rRr5+ZG/lWeRsyrClLYRq7s/yFQ/XhWCA==
dependencies:
lru-cache "^5.1.1"

opencollective-postinstall@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259"
Expand Down Expand Up @@ -7918,10 +7932,10 @@ saxes@^5.0.0:
dependencies:
xmlchars "^2.2.0"

semantic-release@^17.3.1:
version "17.3.1"
resolved "https://registry.yarnpkg.com/semantic-release/-/semantic-release-17.3.1.tgz#8904ef1ca8e704394de0e204b284f6c252284da4"
integrity sha512-NSdxvnBTklrRBYRexVUx44Hri9sTu9b8x+1HfWDGIWemDTFQfWOTbT1N3oy5l8WcZHodhRvtyI7gm50SfAa3Fg==
semantic-release@^17.3.2:
version "17.3.2"
resolved "https://registry.yarnpkg.com/semantic-release/-/semantic-release-17.3.2.tgz#89c793ed64fe00b7bfe1c36bc389fb04855a4df9"
integrity sha512-S8ppLzFFeznDXvRGEvltuwpRT7Tb7o3gBIqaVnahi0sAzrxD/WdWZQoHOpwypzTBD7i9gCxZ+RqVpaHa9WFD3w==
dependencies:
"@semantic-release/commit-analyzer" "^8.0.0"
"@semantic-release/error" "^2.2.0"
Expand Down Expand Up @@ -8063,6 +8077,31 @@ shellwords@^0.1.1:
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==

shiki-languages@^0.2.7:
version "0.2.7"
resolved "https://registry.yarnpkg.com/shiki-languages/-/shiki-languages-0.2.7.tgz#7230b675b96d37a36ac1bf995525375ce69f3924"
integrity sha512-REmakh7pn2jCn9GDMRSK36oDgqhh+rSvJPo77sdWTOmk44C5b0XlYPwJZcFOMJWUZJE0c7FCbKclw4FLwUKLRw==
dependencies:
vscode-textmate "^5.2.0"

shiki-themes@^0.2.7:
version "0.2.7"
resolved "https://registry.yarnpkg.com/shiki-themes/-/shiki-themes-0.2.7.tgz#6e04451d832152e0fc969876a7bd926b3963c1f2"
integrity sha512-ZMmboDYw5+SEpugM8KGUq3tkZ0vXg+k60XX6NngDK7gc1Sv6YLUlanpvG3evm57uKJvfXsky/S5MzSOTtYKLjA==
dependencies:
json5 "^2.1.0"
vscode-textmate "^5.2.0"

shiki@^0.2.7:
version "0.2.7"
resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.2.7.tgz#d2547548ed8742673730e1e4bbe792a77c445540"
integrity sha512-bwVc7cdtYYHEO9O+XJ8aNOskKRfaQd5Y4ovLRfbQkmiLSUaR+bdlssbZUUhbQ0JAFMYcTcJ5tjG5KtnufttDHQ==
dependencies:
onigasm "^2.2.5"
shiki-languages "^0.2.7"
shiki-themes "^0.2.7"
vscode-textmate "^5.2.0"

signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
Expand Down Expand Up @@ -8898,27 +8937,27 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typedoc-default-themes@^0.11.4:
version "0.11.4"
resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.11.4.tgz#1bc55b7c8d1132844616ff6f570e1e2cd0eb7343"
integrity sha512-Y4Lf+qIb9NTydrexlazAM46SSLrmrQRqWiD52593g53SsmUFioAsMWt8m834J6qsp+7wHRjxCXSZeiiW5cMUdw==
typedoc-default-themes@0.12.1:
version "0.12.1"
resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.12.1.tgz#6c4a759f9dc365b4021579587b3773deb6fb6eeb"
integrity sha512-6PEvV+/kWAJeUwEtrKgIsZQSbybW5DGCr6s2mMjHsDplpgN8iBHI52UbA+2C+c2TMCxBNMK9TMS6pdeIdwsLSw==

typedoc@^0.19.2:
version "0.19.2"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.19.2.tgz#842a63a581f4920f76b0346bb80eb2a49afc2c28"
integrity sha512-oDEg1BLEzi1qvgdQXc658EYgJ5qJLVSeZ0hQ57Eq4JXy6Vj2VX4RVo18qYxRWz75ifAaYuYNBUCnbhjd37TfOg==
typedoc@^0.20.14:
version "0.20.14"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.20.14.tgz#894ff71841a4abbe8f46cf52f3cc96c9d68328dc"
integrity sha512-9bsZp5/qkl+gDSv9DRvHbfbY8Sr0tD8fKx7hNIvcluxeAFzBCEo9o0qDCdLUZw+/axbfd9TaqHvSuCVRu+YH6Q==
dependencies:
colors "^1.4.0"
fs-extra "^9.0.1"
handlebars "^4.7.6"
highlight.js "^10.2.0"
lodash "^4.17.20"
lunr "^2.3.9"
marked "^1.1.1"
marked "^1.2.5"
minimatch "^3.0.0"
progress "^2.0.3"
semver "^7.3.2"
shelljs "^0.8.4"
typedoc-default-themes "^0.11.4"
shiki "^0.2.7"
typedoc-default-themes "0.12.1"

typescript@^4.1.3:
version "4.1.3"
Expand Down Expand Up @@ -9163,6 +9202,11 @@ [email protected]:
core-util-is "1.0.2"
extsprintf "^1.2.0"

vscode-textmate@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.2.0.tgz#01f01760a391e8222fe4f33fbccbd1ad71aed74e"
integrity sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==

w3c-hr-time@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd"
Expand Down

0 comments on commit f4e03f8

Please sign in to comment.