twin-scanner-cli
Version:
Find duplicate files in multiple folders scanning .txt and .torrent files.
31 lines (28 loc) • 814 B
text/typescript
export type TOutputFormatTxt = {
filename: string
amount_all_names: number
amount_unique_names: number
amount_duplicates_names: number
readonlyMode: boolean
}[]
export type TConvertToOutputTxt = (options: { readonly: boolean }) => (
raw: Record<
string,
{
unique: string[]
duplicates: string[]
duplicatesLength: number
uniqueLength: number
}
>[],
) => TOutputFormatTxt
export const convertToOutputTxt: TConvertToOutputTxt = options => raw =>
raw.flatMap(val =>
Object.entries(val).map(([absolutePath, ctx]) => ({
filename: absolutePath,
amount_all_names: ctx.duplicatesLength + ctx.uniqueLength,
amount_unique_names: ctx.uniqueLength,
amount_duplicates_names: ctx.duplicatesLength,
readonlyMode: options.readonly,
}))
)