« get me outta code hell

use better package for natural sorting - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/crawlers.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2020-07-17 19:02:18 -0300
committerFlorrie <towerofnix@gmail.com>2020-07-17 19:04:32 -0300
commitba828b4f12779c1ce356ea2c0d99bcb891a09aa0 (patch)
tree333ac430bdad3d086f488832033f7c73fb6b9da6 /crawlers.js
parent8927fb3f3ef9a3d641cf607a756b8815f06c57e2 (diff)
use better package for natural sorting
Diffstat (limited to 'crawlers.js')
-rw-r--r--crawlers.js10
1 files changed, 2 insertions, 8 deletions
diff --git a/crawlers.js b/crawlers.js
index e39dfa1..3f6e391 100644
--- a/crawlers.js
+++ b/crawlers.js
@@ -1,11 +1,11 @@
 const fs = require('fs')
 const path = require('path')
-const naturalSort = require('node-natural-sort')
 const expandHomeDir = require('expand-home-dir')
 const fetch = require('node-fetch')
 const url = require('url')
 const { downloadPlaylistFromOptionValue, promisifyProcess } = require('./general-util')
 const { spawn } = require('child_process')
+const { orderBy } = require('natural-orderby')
 
 const { promisify } = require('util')
 const readDir = promisify(fs.readdir)
@@ -20,12 +20,6 @@ const stat = promisify(fs.stat)
 //   getAllCrawlersForArg.
 const allCrawlers = {}
 
-function sortIgnoreCase(sortFunction) {
-  return function(a, b) {
-    return sortFunction(a.toLowerCase(), b.toLowerCase())
-  }
-}
-
 /* TODO: Removed cheerio, so crawl-http no longer works.
 function crawlHTTP(absURL, opts = {}, internals = {}) {
   // Recursively crawls a given URL, following every link to a deeper path and
@@ -254,7 +248,7 @@ function crawlLocal(dirPath, extensions = [
   }
 
   return readDir(dirPath).then(items => {
-    items.sort(sortIgnoreCase(naturalSort()))
+    items = orderBy(items)
 
     return Promise.all(items.map(item => {
       const itemPath = path.join(dirPath, item)