1.0.2 • Published 4 years ago

ts-walk v1.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

ts-walk

Extract all file or directory/folder paths from a specified directory that justify a set of rules (file extension, etc)

Install

npm i ts-walk

Walk options

Folder/Directory walk options:

option namedescriptiontypedefault value
recursivewalk subfolders or nobooleanfalse
absolutePathsreturn absolute or relative pathsbooleantrue (absolute paths)

File walk options:

option namedescriptiontypedefault value
recursivewalk subfolders or nobooleanfalse
absolutePathsreturn absolute or relative pathsbooleantrue (absolute paths)
fileFilterfilter the returned resultsFileFilternull (no filter)

FileFilter options:

option namedescriptiontypedefault value
allowedExtensionsfilter by allowed extensionsstring[]null (no filter)
sizeBytesfilter by size (in bytes)FilterMinMaxnull (no filter)
lastAccessedMsfilter by last access time timeFilterMinMaxnull (no filter)
lastModifiedMsfilter by last modification time timeFilterMinMaxnull (no filter)
createdMsfilter by max creation timeFilterMinMaxnull (no filter)

FilterMinMax options:

option namedescriptiontypedefault value
minminimum valuenumbernull (no comparison)
maxmaximum valuenumbernull (no comparison)

Usage

import { Walk } from 'ts-walk'

// all files from current folder with full path (absolute_path)
console.log(Walk.files('./'))
// all files from current folder with relative path
console.log(Walk.files('./', { absolutePaths: false }))
// all files from current folder (recursive) with relative path
console.log(Walk.files('./', { recursive: true, absolutePaths: false }))
// all .js and .ts files from current folder (recursive) with relative path
console.log(Walk.files('./', { recursive: true, absolutePaths: false, fileFilter: { allowedExtensions: ['js', 'ts'] }}))
// all .ts files (smaller, than 2000 bytes) from current folder with absolute path
console.log(Walk.files('./src', {
    fileFilter: {
        allowedExtensions: ['ts'],
        sizeBytes: { max: 2000 }
        // lastAccessedMs: null,
        // lastModifiedMs: null,
        // createdMs: null
    }
}))

// all dirs from current folder with full path (absolute_path)
console.log(Walk.dirs('./'))
// all dirs from current folder with relative path
console.log(Walk.dirs('./', { absolutePaths: false }))
// all dirs from current folder (recursive) with relative path
console.log(Walk.dirs('./', { recursive: true, absolutePaths: false }))
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago