From 185f5ec30b9da5ca82325e8d5d81593e09eaf77a Mon Sep 17 00:00:00 2001 From: David Ernst Date: Wed, 5 Feb 2020 09:17:58 -0800 Subject: [PATCH] Remove unnecessary natsort dep --- package-lock.json | 5 ----- package.json | 1 - src/renderer/pages/torrent-list-page.js | 5 ++--- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9cd37a87..adb956d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6540,11 +6540,6 @@ "integrity": "sha512-dndRmy03JQEN+Nh6WjQl7/OstIozeEmrtWe4TE7mEqJ8W8oMD8m2tHjsLPWt//e3hLAeRSbs4pxMyc5pk/nCkQ==", "optional": true }, - "natsort": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/natsort/-/natsort-1.0.6.tgz", - "integrity": "sha1-/U9GMfrH9Yhap39x/VWidC2U6zI=" - }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", diff --git a/package.json b/package.json index 338b9d3b..ffb08d85 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "material-ui": "^0.20.2", "mkdirp": "^0.5.1", "music-metadata": "^3.6.1", - "natsort": "^1.0.6", "network-address": "^1.1.0", "parse-torrent": "^6.0.1", "prettier-bytes": "^1.0.1", diff --git a/src/renderer/pages/torrent-list-page.js b/src/renderer/pages/torrent-list-page.js index ab240364..385541e1 100644 --- a/src/renderer/pages/torrent-list-page.js +++ b/src/renderer/pages/torrent-list-page.js @@ -1,6 +1,5 @@ const React = require('react') const prettyBytes = require('prettier-bytes') -const natsort = require('natsort') const Checkbox = require('material-ui/Checkbox').default const LinearProgress = require('material-ui/LinearProgress').default @@ -280,13 +279,13 @@ module.exports = class TorrentList extends React.Component { } else { // We do know the files. List them and show download stats for each one const sortByName = this.props.state.saved.prefs.sortByName - const sorter = natsort() + const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }) let fileRows = torrentSummary.files .filter((file) => !file.path.includes('/.____padding_file/')) .map((file, index) => ({ file, index })) if (sortByName) { - fileRows = fileRows.sort((a, b) => sorter(a.file.name, b.file.name)) + fileRows = fileRows.sort((a, b) => collator.compare(a.file.name, b.file.name)) } fileRows = fileRows.map((obj) => this.renderFileRow(torrentSummary, obj.file, obj.index))