fs-lockfile
Managing the reading and writing of files in the application.
Only one action can manipulate file in the mean time.
No Dependencies.
Installation
npm i --save fs-lockfile
Method of fs-lockfile
-
read(filePath): Promise
-
write(filePath, content): Promise
-
obtainReadLock(filePath): Object
-
obtainWriteLock(filePath): Object
-
releaseReadLock(lockMeta): undefined
-
releaseWriteLock(lockMeta): undefined
Usage
Example:
const path = const read write = { await const content = await console} const filePath = path
Another example:
{ if !path throw 'Must be an absolute path.' const lockMeta = await try return await fsp catch readError throw readError finally await }
LISENCE
MIT