Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
custom-file
Advanced tools
It abstracts the File and Folder classes, can be used on any virtual file system, and stream supports.
It abstracts the File and Folder classes, can be used on any virtual file system, and stream supports.
you must set the fs
(file system) to AbstractFile Before use it:
through2 = require 'through2'
Stream = require('stream').Stream
fs = require 'graceful-fs' #or require 'fs'
CustomFile = require 'custom-file'
fs.cwd = process.cwd # what's the current working directory.
CustomFile.setFileSystem(fs) # and should set your filesystem first.
File = CustomFile.File
Folder = CustomFile.Folder
file = File './readme.md', load:true, read:true, buffer:true
console.log file.contents #<Buffer 23...>
file = File './readme.md', load:true, read:true
console.log file.contents instanceof Stream #true
file.pipe process.stdout, end:false #pipe to stdout(the stdout should be never closed.)
file = Folder './', load:true, read:true, buffer:true
console.log file.contents #[<File "README.md">, <Folder "src">,...]
file = Folder './', load:true, read:true
console.log file.contents instanceof Stream #true
file.pipe through2.obj (aFile, enc, next)->next null, aFile.inspect()+'\n'
.pipe process.stdout, end:false
the following is javascript:
var through2 = require('through2');
var Stream = require('stream').Stream;
var fs = require('graceful-fs');
var CustomFile = require('custom-file');
fs.cwd = process.cwd;
CustomFile.setFileSystem(fs);
var File = CustomFile.File;
var Folder = CustomFile.Folder;
var file = File('./readme.md', {
load: true,
read: true,
buffer: true
});
console.log(file.contents);
file = File('./readme.md', {
load: true,
read: true
});
console.log(file.contents instanceof Stream);
file.pipe(process.stdout, {
end: false
});
file = Folder('./', {
load: true,
read: true,
buffer: true
});
console.log(file.contents);
file = Folder('./', {
load: true,
read: true
});
console.log(file.contents instanceof Stream);
file.pipe(through2.obj(function(aFile, enc, next) {
return next(null, aFile.inspect() + '\n');
})).pipe(process.stdout, {
end: false
});
The FileInfo properties:
cwd
(String): the current working directory.
"root"
if cwd
is ''.path
(String): the file path. it will be stored as absolute path always.
path
= path.resolve(cwd
, path
)name
(String): the name of the file. = basename
base
(String): the file base path. it is absolute path always.
cwd
will be the file base path if emptyhistory
(Array): the history of this file path changes.
contents
(Buffer|Array|Stream): the contents of this file.
stat
(Stats): the stats of this file.
isDirectory()
should be exists.computed properties:
dirname
(String): the dirname of this file.basename
(String): the basename of this file.extname
(String): the extname of this file.relative
(String): the relative path of this file.
base
, path
) if base
is absolute pathcwd
, path
) if no base
propertymethods:
MIT
FAQs
It abstracts the File and Folder classes, can be used on any virtual file system, and stream supports.
The npm package custom-file receives a total of 9 weekly downloads. As such, custom-file popularity was classified as not popular.
We found that custom-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.