@neurodevs/node-file-checker
TypeScript icon, indicating that this package has built-in type declarations

0.3.10 • Public • Published

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()

Readme

Keywords

none

Package Sidebar

Install

npm i @neurodevs/node-file-checker

Weekly Downloads

11

Version

0.3.10

License

none

Unpacked Size

32.6 kB

Total Files

31

Last publish

Collaborators

  • ericthecurious