Skip to content

neurodevs/node-file-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-file-checker

Check whether file exists with optional timeout

Installation

npm install @neurodevs/node-file-checker

Static Creation Method

import { FileCheckerImpl } from '@neurodevs/node-file-checker'

const checker = FileCheckerImpl.Checker()

Check If File Exists

import { FileCheckerImpl } from '@neurodevs/node-file-checker'

const path = '...'
const checker = FileCheckerImpl.Checker()

// Needs to be in an async function
const wasFound = await checker.checkIfFileExists(path)

Check with a Timeout (Default: No timeout)

import { FileCheckerImpl } from '@neurodevs/node-file-checker'

const path = '...'
const timeoutMs = 1000

const checker = FileCheckerImpl.Checker({ timeoutMs })

// Needs to be in an async function
const wasFound = await checker.checkIfFileExists(path)

Use a Test Double in Your Tests

import { FileCheckerImpl, FakeFileChecker } from '@neurodevs/node-file-checker'

FileCheckerImpl.Class = FakeFileChecker
const fakeChecker = FileCheckerImpl.Checker()

Create Your Own Test Double

import { FileChecker } from '@neurodevs/node-file-checker'

class MockFileChecker implements FileChecker {
    ...
}

FileCheckerImpl.Class = MockFileChecker
const mockChecker = FileCheckerImpl.Checker()

About

Check whether file exists with timeout

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •