1.1.0 • Published 6 years ago

@guseyn/cutie-fs v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

cutie-fs

NPM Version Build Status codecov

Cutie extension for fs module in Node. It's based on the Async Tree Pattern.

Examples

You can find examples of using this library in the test directory.

Install

npm install @cuties/fs

Run test

npm test

Run build

npm run build

Usage

const {
  // Needed async objects here from the table below
} = require('@cuties/fs');

For more information about parameters in the async objects visit docs of Node for fs module.

data

Async ObjectAsync/sync callParameters(default value/description)Representation result
ReadBufferByFDfs.readfd, buffer, offset, length, positionbuffer
ReadBufferByFDSyncfs.readSyncfd, buffer, offset, length, positionbuffer
ReadDataByPathfs.readFilepath, options({encoding: null, flag: 'r'})buffer or string
ReadDataByPathSyncfs.readFileSyncpath, options({encoding: null, flag: 'r'})buffer or string
ReadDataFromFilesreadDataFromFilesfiles, options({encoding: null, flag: 'r'})object: {fileName1: data1, fileName2: data2, ... }
ReadLinkByPathfs.readlinkpath, options('utf8')linkstring
ReadLinkByPathSyncfs.readlinkSyncpath, options('utf8')linkstring
WrittenBufferByFDfs.writefd, buffer[, offset[, length[, position]]]buffer
WrittenDataByFDfs.writefd, string[, position[, encoding]]string
WrittenDataByFDfs.writeSyncfd, string[, position[, encoding]]string
WrittenDataToFileswrittenDataToFilesfilesWithData({fileName1: data1, fileName2: data2, ... }), options({encoding: null, flag: 'r'})filesWithData

file

Async ObjectAsync/sync callParameters(default value/description)Representation result
AccessibleFilefs.accesspath, mode (fs.constants.F_OK)file(as path) or error
AccessibleFileSyncfs.accessSyncpath, mode(fs.constants.F_OK)file(as path) or error
AppendedFilefs.appendFilefile, data, options({encoding: 'utf8', mode: 0o666, flag: 'a'})file
AppendedFileSyncfs.appendFileSyncfile, data, options({encoding: 'utf8', mode: 0o666, flag: 'a'})file
ClosedFilefs.closefdfile(as fd)
CopiedFilefs.copyFilesrc, dest, flags(0)files(as dest)
CopiedFileSyncfs.copyFileSyncsrc, dest, flags(0)files(as dest)
CreatedDirectoryfs.mkdirpath, mode(0o777)file(as path)
CreatedDirectorySyncfs.mkdirSyncpath, mode(0o777)file(as path)
CreatedTemporaryDirectoryfs.mkdtempprefix, options('utf8')file(dir)
CreatedTemporaryDirectorySyncfs.mkdtempSyncprefix, options('utf8')file(dir)
DeletedDirectoryfs.rmdirpathfile(as path)
DeletedDirectorySyncfs.rmdirSyncpathfile(as path)
DoesFileExistSyncpathfs.existsSyncboolean
FileWithChangedOwnerByFDfs.fchownfd, uid, gidfile(as fd)
FileWithChangedOwnerByFDSyncfs.fchownSyncfd, uid, gidfile(as fd)
FileWithChangedPermissionsByFDfs.fchmodfd, modefile(as fd)
FileWithChangedPermissionsByFDSyncfs.fchmodSyncfd, modefile(as fd)
FileWithChangedPermissionsByPathfs.chmodpath, modefile(as path)
FileWithChangedPermissionsByPathSyncfs.chmodSyncpath, modefile(as path)
FileWithChangedTimesByFDfs.futimesfd, atime, mtimefile(as fd)
FileWithChangedTimesByFDSyncfs.futimesSyncfd, atime, mtimefile(as fd)
FileWithChangedTimesByPathfs.utimespath, atime, mtimefile(as path)
FileWithChangedTimesByPathSyncfs.utimesSyncpath, atime, mtimefile(as path)
FileWithSyncedDatafs.fdatasyncfdfile(as fd)
FileWithSyncedDataSyncfs.fdatasyncSyncfdfile(as fd)
LinkedFilefs.linkexistingPath, newPathfile(as newPath)
LinkedFileSyncfs.linkSyncexistingPath, newPathfile(as newPath)
LinkedFileWithChangedOwnerByPathfs.lchownpath, uid, gidfile(as path)
LinkedFileWithChangedOwnerByPathSyncfs.lchownSyncpath, uid, gidfile(as path)
OpenedFilefs.openpath, flags, mode(0o666)file(as fd)
OpenedFileSyncfs.openSyncpath, flags, mode(0o666)file(as fd)
RenamedFilefs.renameoldPath, newPathfile(as newPath)
RenamedFileSyncfs.renameSyncoldPath, newPathfile(as newPath)
SymbolicLinkedFilefs.symlinktarget, path, type('file')file(as path)
SymbolicLinkedFileSyncfs.symlinkSynctarget, path, type('file')file(as path)
SyncedFilefs.fsyncfdfile(as fd)
SyncedFileSyncfs.fsyncSyncfdfile(as fd)
TruncatedFileByFDfs.ftruncatefd, len(0)file(as fd)
TruncatedFileByFDSyncfs.ftruncateSyncfd, len(0)file(as fd)
UnlinkedFilefs.unlinkpathfile(as path)
UnlinkedFileSyncfs.unlinkSyncpathfile(as path)
UnwatchedFilefs.unwatchFilefileName, listenerfile(as fileName)
WrittenFilefs.writeFilefile, data, options({encoding: 'utf8', mode: 0o666, flag: 'w'})file
WrittenFileSyncfs.writeFileSyncfile, data, options({encoding: 'utf8', mode: 0o666, flag: 'w'})file

files

Async ObjectAsync/sync callParameters(default value/description)Representation result
CopiedDirectoryRecursivelycopiedDirectoryRecursivelydir, dest, options('utf8')dest
DeletedDirectoryRecursivelydeletedDirectoryRecursivelydir, options('utf8')dir
ReadFilesOfDirectoryfs.readdirpath, options('utf8')file[]
ReadFilesOfDirectorySyncfs.readdirSyncpath, options('utf8')file[]
ReadFilesOfDirectoryRecursivelyreadFilesOfDirectoryRecursivelypath, options('utf8')file[]

read-stream

Async ObjectAsync/sync callParameters(default value/description)Representation result
BytesReadFromReadStreamreadStream.bytesReadreadStreamthe number of bytes read so far
CreatedReadStreamfs.createReadStreampath, options({flags: 'r', encoding: null, fd: null, mode: 0o666, autoClose: true, highWaterMark: 64 * 1024})ReadStream
PathOfReadStreamreadStream.pathreadStreamthe path to the file the stream is reading
ReadStreamWithCloseEventreadStream.on('close', event)readStream, event(Event with definedBody())readStream
ReadStreamWithOpenEventreadStream.on('open', event)readStream, event(Event with definedBody(fd))readStream

stats

Async ObjectAsync/sync callParameters(default value/description)Representation result
BirthTimestats.birthtimestatstime
BirthTimeInMsstats.birthtimeMsstatsnumber
BlkSizestats.blksizestatsnumber
Blocksstats.blocksstatsnumber
Devstats.devstatsnumber
Gidstats.gidstatsnumber
Inostats.inostatsnumber
IsBlockDevicestats.isBlockDevicestatsboolean
IsCharacterDevicestats.isCharacterDevicestatsboolean
IsDirectorystats.isDirectorystatsboolean
IsFIFOstats.isFIFOstatsboolean
IsFilestats.isFilestatsboolean
IsSocketstats.isSocketstatsboolean
IsSymbolicLinkstats.isSymbolicLinkstatsboolean
LastAccessedTimestats.atimestatstime
LastAccessedTimeInMsstats.atimeMsstatsnumber
LastChangedTimestats.ctimestatstime
LastChangedTimeInMsstats.ctimeMsstatsnumber
LastModifiedTimestats.mtimestatstime
LinkedStatsfs.lstatpathstats
LinkedStatsSyncfs.lstatSyncpathstats
Modestats.modestatsnumber
Nlinkstats.nlinkstatsnumber
RDevstats.rdevstatsrdev
RealPathstats.realpathpath, options('utf8')path
RealPathSyncstats.realpathSyncpath, options('utf8')path
Sizestats.sizestatsnumber
StatsByFDfs.fstatfdstats
StatsByFDSyncfs.fstatSyncfdstats
StatsByPathfs.statpathstats
StatsByPathSyncfs.statSyncpathstats

watcher

Async ObjectAsync/sync callParameters(default value/description)Representation result
ClosedWatcherwatcher.closewatcherFSWatcher
WatcherWithCurrentAndPreviousStatsListenerfs.watchFilefilename, options({persistent: true, interval: 5007}), listener(Event with definedBody(current, previous))FSWatcher
WatcherWithErrorEventwatcher.on('error', event)watcher, event(Event with definedBody(error))FSWatcher
WatcherWithEventTypeAndFilenameListenerfs.watchfilename, options({persistent: true, recursive: false, encoding: 'utf8'}), listener(Event with definedBody(eventType, filename))FSWatcher

write-stream

Async ObjectAsync/sync callParameters(default value/description)Representation result
BytesWrittenToWriteStreamwriteStream.bytesWrittenwriteStreamthe number of bytes written so far
CreatedWriteStreamfs.createWriteStreampath, options ({flags: 'w', encoding: 'utf8', fd: null, mode: 0o666, autoClose: true})WriteStream
PathOfWriteStreamwriteStream.pathwriteStreamthe path to the file the stream is writing
WriteStreamWithCloseEventwriteStream.on('close', event)writeStream, event(Event with definedBody())WriteStream
WriteStreamWithOpenEventwriteStream.on('open', event)writeStream, event(Event with definedBody(fd))WriteStream