
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
Class for manipulating file system in a synchronous way using NodeJS.
You can create/remove directories recursively and read/write files too.
I use it mainly as base for file generators.
const jfFileSystem = require('@jf/fs');
const path = require('path');
const tr = require('./translations');
class Generator extends jfFileSystem {
constructor(directory)
{
this.directory = directory;
// Clean directory recursively before generating files.
this.rmdir(directory);
}
generate(data)
{
// If outfile has several levels of depth, no problem.
// `write` method will create all required directories.
data.forEach(
config => this.write(
path.join(
this.directory,
config.outfile
),
this.parse(config.data)
)
);
}
log(level, name, label, ...args)
{
// Translating logs.
// tr is a map with translations.
super.log(level, name, tr[label], ...args);
}
parse(data)
{
// In your class, process data and convert it to string.
return JSON.stringify(data);
}
}
All texts are in spanish but if you want to translate them you can
overwrite log method in child class (as in the previous example)
or to listen log event.
const chalk = require('chalk');
const siNumber = require('si-number');
const fs = require('@jf/fs').i();
fs.on(
'log',
data =>
{
// Show only errors
if (data.level === 'error')
{
const _args = data.args;
if (Array.isArray(_args))
{
_args.forEach(
(arg, index) =>
{
if (typeof arg === 'number')
{
// Format number in green using SI prefixes.
_args[index] = chalk.green(
siNumber(
arg,
{
decimal : ',',
precision : 1,
thousands : true
}
)
);
}
else
{
// Texts in cyan.
_args[index] = chalk.cyan(arg);
}
}
)
}
}
else
{
delete data.label;
}
}
);
fs.log('info', '', 'Test %s', 'pl1'); // Omitted because is not an error.
fs.log('error', '', 'File %s already exists', '/tmp/exists.js'); // Filename in cyan
fs.log('error', '', 'Filesize %s', 1324); // Number formatted in green as 1,3k
FAQs
Class for manipulating file system in a synchronous way with useful methods.
The npm package @jf/fs receives a total of 2 weekly downloads. As such, @jf/fs popularity was classified as not popular.
We found that @jf/fs demonstrated a healthy version release cadence and project activity because the last version was released less than 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.