From f4e03f8eb87d9fae62bfb92f31775899271cd1d8 Mon Sep 17 00:00:00 2001 From: lzear Date: Wed, 13 Jan 2021 23:41:57 +0100 Subject: [PATCH] fix: use lodash-es --- package.json | 8 +-- src/methods/baldwin/index.ts | 2 +- src/methods/coombs/index.ts | 2 +- src/methods/copeland/index.ts | 4 +- src/methods/kemeny/index.ts | 4 +- src/methods/maximal-lotteries/index.ts | 2 +- src/methods/nanson/index.ts | 4 +- src/methods/ranked-pairs/index.ts | 8 +-- src/methods/schulze/index.ts | 2 +- src/test/matrix.ts | 2 +- src/test/testUtils.ts | 8 +-- src/utils/condorcet.ts | 2 +- src/utils/makeMatrix.ts | 6 +- src/utils/normalize.ts | 12 ++-- src/utils/scores.ts | 6 +- src/utils/scoresZero.ts | 2 +- tsconfig.json | 2 +- yarn.lock | 94 +++++++++++++++++++------- 18 files changed, 107 insertions(+), 63 deletions(-) diff --git a/package.json b/package.json index 118aeaf..64f745e 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" diff --git a/src/methods/baldwin/index.ts b/src/methods/baldwin/index.ts index 388e308..504399d 100644 --- a/src/methods/baldwin/index.ts +++ b/src/methods/baldwin/index.ts @@ -1,4 +1,4 @@ -import difference from 'lodash/difference' +import difference from 'lodash-es/difference' import { SystemUsingRankings, ScoreObject, diff --git a/src/methods/coombs/index.ts b/src/methods/coombs/index.ts index 09e629d..4c49c5d 100644 --- a/src/methods/coombs/index.ts +++ b/src/methods/coombs/index.ts @@ -1,4 +1,4 @@ -import difference from 'lodash/difference' +import difference from 'lodash-es/difference' import { SystemUsingRankings, ScoreObject, diff --git a/src/methods/copeland/index.ts b/src/methods/copeland/index.ts index 7100ec9..366fda7 100644 --- a/src/methods/copeland/index.ts +++ b/src/methods/copeland/index.ts @@ -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, diff --git a/src/methods/kemeny/index.ts b/src/methods/kemeny/index.ts index bd6de2c..166741c 100644 --- a/src/methods/kemeny/index.ts +++ b/src/methods/kemeny/index.ts @@ -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, diff --git a/src/methods/maximal-lotteries/index.ts b/src/methods/maximal-lotteries/index.ts index 97b67d8..836203c 100644 --- a/src/methods/maximal-lotteries/index.ts +++ b/src/methods/maximal-lotteries/index.ts @@ -1,4 +1,4 @@ -import zipObject from 'lodash/zipObject' +import zipObject from 'lodash-es/zipObject' import { solve } from '../../simplex' import { SystemUsingMatrix, diff --git a/src/methods/nanson/index.ts b/src/methods/nanson/index.ts index 3e01811..cf33dad 100644 --- a/src/methods/nanson/index.ts +++ b/src/methods/nanson/index.ts @@ -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, diff --git a/src/methods/ranked-pairs/index.ts b/src/methods/ranked-pairs/index.ts index e99ec1e..3146d07 100644 --- a/src/methods/ranked-pairs/index.ts +++ b/src/methods/ranked-pairs/index.ts @@ -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, diff --git a/src/methods/schulze/index.ts b/src/methods/schulze/index.ts index 90e79e9..06c7b5e 100644 --- a/src/methods/schulze/index.ts +++ b/src/methods/schulze/index.ts @@ -1,5 +1,5 @@ /* eslint-disable no-plusplus */ -import range from 'lodash/range' +import range from 'lodash-es/range' import { SystemUsingMatrix, VotingSystem, diff --git a/src/test/matrix.ts b/src/test/matrix.ts index 45baadc..0c1e6a7 100644 --- a/src/test/matrix.ts +++ b/src/test/matrix.ts @@ -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] diff --git a/src/test/testUtils.ts b/src/test/testUtils.ts index 755e2ab..2a73311 100644 --- a/src/test/testUtils.ts +++ b/src/test/testUtils.ts @@ -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' diff --git a/src/utils/condorcet.ts b/src/utils/condorcet.ts index 0bcdbea..601b6dd 100644 --- a/src/utils/condorcet.ts +++ b/src/utils/condorcet.ts @@ -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 => { diff --git a/src/utils/makeMatrix.ts b/src/utils/makeMatrix.ts index 9da0547..ad34597 100644 --- a/src/utils/makeMatrix.ts +++ b/src/utils/makeMatrix.ts @@ -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 = ( diff --git a/src/utils/normalize.ts b/src/utils/normalize.ts index 8767463..4d19840 100644 --- a/src/utils/normalize.ts +++ b/src/utils/normalize.ts @@ -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' diff --git a/src/utils/scores.ts b/src/utils/scores.ts index 5298d61..5d9b2f7 100644 --- a/src/utils/scores.ts +++ b/src/utils/scores.ts @@ -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 diff --git a/src/utils/scoresZero.ts b/src/utils/scoresZero.ts index dfe2cfe..2f1cb49 100644 --- a/src/utils/scoresZero.ts +++ b/src/utils/scoresZero.ts @@ -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 => diff --git a/tsconfig.json b/tsconfig.json index 587d9d7..94b09ba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "moduleResolution": "node", - "target": "es5", + "target": "esnext", "module": "es2015", "lib": ["es7", "es2015", "es2016", "es2017", "es2019", "esnext", "dom"], "strict": true, diff --git a/yarn.lock b/yarn.lock index d8beb08..685a473 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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== @@ -2584,7 +2591,7 @@ colors@1.0.3: 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== @@ -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" @@ -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= -json5@2.x, json5@^2.1.2: +json5@2.x, 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== @@ -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" @@ -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== @@ -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" @@ -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" @@ -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" @@ -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" @@ -9163,6 +9202,11 @@ verror@1.10.0: 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"