🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

simple-typed-fetch

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-typed-fetch - npm Package Compare versions

Comparing version

to
0.1.7

35

dist/index.js

@@ -35,4 +35,5 @@ // src/index.ts

});
if (fetchResult.isErr())
if (fetchResult.isErr()) {
return fetchResult.error;
}
const response = fetchResult.value;

@@ -55,4 +56,5 @@ const textResult = await fromPromise(response.text(), (e) => {

});
if (textResult.isErr())
if (textResult.isErr()) {
return textResult.error;
}
const text = textResult.value;

@@ -68,23 +70,28 @@ if (response.status >= 500) {

}
const safeParseJson = fromThrowable(JSON.parse, (e) => {
if (e instanceof Error) {
const safeParseJson = fromThrowable(
JSON.parse,
(e) => {
if (e instanceof Error) {
return err({
type: "jsonParseError",
url,
message: e.message,
error: e
});
}
return err({
type: "jsonParseError",
type: "jsonParseUnknownError",
url,
message: e.message,
message: "Unknown JSON parse error",
error: e
});
}
return err({
type: "jsonParseUnknownError",
url,
message: "Unknown JSON parse error",
error: e
});
});
);
const jsonResult = safeParseJson(text);
if (jsonResult.isErr()) {
const textPayload = schema.safeParse(text);
if (textPayload.success)
if (textPayload.success) {
return ok(textPayload.data);
}
jsonResult.error.error.message = `Can't parse response as JSON: ${jsonResult.error.error.message}. Original response: ${text}`;
return jsonResult.error;

@@ -91,0 +98,0 @@ }

@@ -7,3 +7,3 @@ {

},
"version": "0.1.6",
"version": "0.1.7",
"description": "Making HTTP requests human way",

@@ -47,5 +47,11 @@ "main": "./dist/index.cjs",

"devDependencies": {
"@typescript-eslint/eslint-plugin": ">=5.57.1",
"@typescript-eslint/parser": ">=5.57.1",
"eslint": ">=8.37.0",
"eslint-config-xo": "^0.43.1",
"eslint-config-xo-typescript": "^0.57.0",
"rimraf": "^4.4.1",
"tsup": "^6.7.0"
"tsup": "^6.7.0",
"typescript": "^5.0.3"
}
}
dist/index.cjs

Sorry, the diff of this file is not supported yet