« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/playlist-utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/playlist-utils.js')
-rw-r--r--src/playlist-utils.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/playlist-utils.js b/src/playlist-utils.js
index 5efd478..aed4964 100644
--- a/src/playlist-utils.js
+++ b/src/playlist-utils.js
@@ -245,6 +245,14 @@ function getPlaylistTreeString(playlist, showTracks = false) {
   return recursive(playlist)
 }
 
+function getItemPath(item) {
+  if (item[parentSymbol]) {
+    return [...getItemPath(item[parentSymbol]), item]
+  } else {
+    return [item]
+  }
+}
+
 function getItemPathString(item) {
   // Gets the playlist path of an item by following its parent chain.
   // Returns a string in format Foo/Bar/Baz, where Foo and Bar are group
@@ -286,7 +294,7 @@ module.exports = {
   filterPlaylistByPathString, filterGrouplikeByPath,
   removeGroupByPathString, removeGroupByPath,
   getPlaylistTreeString,
-  getItemPathString,
+  getItemPath, getItemPathString,
   parsePathString,
   isGroup, isTrack
 }