Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
hot-file-cache
Advanced tools
A watched file cache which will invalidate automatically if the source changes
A file/glob cache which will invalidate automatically if the source changes (powered by chokidar)
Install the plugin with npm:
$ npm install --save-dev hot-file-cache
var hfc = new HotFileCache('*.md', {cwd: dir});
hfc.readFile('README.md').then(function(content) {
console.log(content);
});
var hfc = new HotFileCache('*.json', {
cwd: dir,
// the fileProcessor will be executed only once per file
fileProcessor: function (filename, fileContent) {
// the return value could also be a promise
return JSON.parse(fileContent);
}
});
hfc.readFile('demo.json').then(function(content) {
console.log(content);
});
All options except the fileProcessor
are equal to chokidar.
Because of the asynchronous nature of disk operations all functions return a Promise
.
getFiles()
getFiles returns an array of all absolute filenames matching the pattern. As it looks into a warm cache it doesn't need any disk operations.
fileExists(absolutePath)
fileExists returns true if the given file exists.
As it looks in into a warm cache it doesn't need any disk operations.
readFile(absolutePath)
readFile returns the content of the given file.
If a file processor is passed the content is also processed.
The processed result is cached until chokidar
detects a file change on the disk.
var hfc = new HotFileCache('*.json', {
cwd: dir,
fileProcessor: function process (filename, fileContent) {
return JSON.parse(fileContent);
}
});
hfc.readFile('demo.json') // 1
.then(function(content) {
console.log(content);
});
hfc.readFile('demo.json') // 2
.then(function(content) {
console.log(content);
});
hfc.readFile('demo.json') // 3
.then(function(content) {
console.log(content);
});
hfc.readFile('demo.json') // 4
.then(function(content) {
console.log(content);
});
Take a look at the CHANGELOG.md.
You're free to contribute to this project by submitting issues and/or pull requests. This project is test-driven, so keep in mind that every change and new feature should be covered by tests. This project uses the semistandard code style.
This project is licensed under MIT.
0.0.9
FAQs
A watched file cache which will invalidate automatically if the source changes
The npm package hot-file-cache receives a total of 4 weekly downloads. As such, hot-file-cache popularity was classified as not popular.
We found that hot-file-cache 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.