« get me outta code hell

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:
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)