diff options
author | 2022-04-17 22:30:40 +0900 | |
---|---|---|
committer | 2022-04-17 15:30:40 +0200 | |
commit | 531d4c106c0a5ed3dcdcb350509beedfd24a8253 (patch) | |
tree | f885fcb66215fe549588ab880b44789a1eae7e8f /source/helpers/get-items-between.ts | |
parent | c73f29b0aa136a5e9579ff55fca725f610718573 (diff) | |
download | refined-github-531d4c106c0a5ed3dcdcb350509beedfd24a8253.tar.gz refined-github-531d4c106c0a5ed3dcdcb350509beedfd24a8253.tar.zst refined-github-531d4c106c0a5ed3dcdcb350509beedfd24a8253.zip |
Allow `batch-mark-files-as-viewed` to mark all files from first (#5587)
Co-authored-by: cheap-glitch <cheap.glitch@gmail.com>
Co-authored-by: Federico Brigante <me@fregante.com>
Diffstat (limited to 'source/helpers/get-items-between.ts')
-rw-r--r-- | source/helpers/get-items-between.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/helpers/get-items-between.ts b/source/helpers/get-items-between.ts new file mode 100644 index 00000000..75221535 --- /dev/null +++ b/source/helpers/get-items-between.ts @@ -0,0 +1,9 @@ +/** +Get the items between previous and current, both ends included. If `previous` is missing, start from 0 +*/ +export default function getItemsBetween<T>(items: T[], previous: T | undefined, current: T): T[] { + const start = previous ? items.indexOf(previous) : 0; + const end = items.indexOf(current); + + return items.slice(Math.min(start, end), Math.max(start, end) + 1); +} |