Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jsenv/filesystem

Package Overview
Dependencies
Maintainers
0
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/filesystem - npm Package Compare versions

Comparing version 4.9.5 to 4.9.6

4

package.json
{
"name": "@jsenv/filesystem",
"version": "4.9.5",
"version": "4.9.6",
"license": "MIT",

@@ -34,3 +34,3 @@ "repository": {

"dependencies": {
"@jsenv/urls": "2.4.1",
"@jsenv/urls": "2.5.0",
"@jsenv/url-meta": "8.5.0",

@@ -37,0 +37,0 @@ "@jsenv/abort": "4.3.0",

@@ -0,1 +1,2 @@

import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
import { readFileSync as readFileSyncNode } from "node:fs";

@@ -5,4 +6,14 @@

export const readFileSync = (value, { as = "buffer" } = {}) => {
export const readFileSync = (value, { as } = {}) => {
const fileUrl = assertAndNormalizeFileUrl(value);
if (as === undefined) {
const contentType = CONTENT_TYPE.fromUrlExtension(fileUrl);
if (CONTENT_TYPE.isJson(contentType)) {
as = "json";
} else if (CONTENT_TYPE.isTextual(contentType)) {
as = "string";
} else {
as = "buffer";
}
}
const buffer = readFileSyncNode(new URL(fileUrl));

@@ -9,0 +20,0 @@ if (as === "buffer") {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc