Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
read-file-safe
Advanced tools
Read files without try catch.
If I should maintain this repo, please ⭐️
DM me on Twitter if you have questions or suggestions.
This package handles filesystem errors for you. If a file does not exist or cannot be accessed, undefined
is returned instead of throwing an error.
yarn add read-file-safe
npm install read-file-safe
pnpm add read-file-safe
By default, readFile
and readFileSync
return a string:
import { readFile, readFileSync } from "read-file-safe";
const path = "./path/to/file.ext";
const file = readFile(path); // Promise<string | undefined>
const file = readFileSync(path); // string | undefined
Setting the buffer
option to true
will return a Buffer
instead of a string:
import { readFile, readFileSync } from "read-file-safe";
const file = readFile(path, { buffer: true }); // Promise<Buffer | undefined>
const file = readFileSync(path, { buffer: true }); // Buffer | undefined
Setting the compression
option will decompress the file before returning it. Both gzip
and brotli
are supported:
import { readFile, readFileSync } from "read-file-safe";
const file = readFile(path, { compression: "gzip" }); // Promise<string | undefined>
const file = readFile(path, { compression: "brotli" }); // Promise<string | undefined>
MIT - MIT License
FAQs
Read files without try catch
The npm package read-file-safe receives a total of 16,144 weekly downloads. As such, read-file-safe popularity was classified as popular.
We found that read-file-safe 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.