0.0.4 • Published 2 years ago
@santimir/group-files v0.0.4
group-files
Groups files from a FileList
, PartialFile
, File[]
or PartialFile[]
with different options.
- Group by
dirPath
ordirPath/basename
- Name the file objects using filename, basename or extension
- Option to lowercase those keys (not the real filenames) for easy-finding,
- etc..
Installation
npm i @santimir/group-files
Simple Example
Copy the src/_data
folder in the current script directory to test, or use your own files.
import { join } from "path";
import { fileListFromPath } from "filelist-from";
import { groupFiles } from "@santimir/group-files";
const files = fileListFromPath(join(__dirname, "_data/biologic"))
console.log(groupFiles(files))
const files = fileListFromPath(join(__dirname, "_data/wdf"))
console.log(groupFiles(files, {
idWithBasename: false,
useExtension: false,
useBasename: true,
lowerCaseFileKey: true
}))