Skip to content

Commit

Permalink
simplify esmodule source
Browse files Browse the repository at this point in the history
  • Loading branch information
akira-cn committed Aug 10, 2023
1 parent 4096260 commit 9e455b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
16 changes: 6 additions & 10 deletions dist/es-modular.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -526,17 +526,13 @@ function makeRpc(url, func) {
'content-type': 'application/json'
}
});
try {
const type = ret.headers.get('content-type');
if(type && type.startsWith('application/json')) {
return await ret.json();
} else if(type && type.startsWith('text/')) {
return await ret.text();
}
return await ret.arrayBuffer();
} catch(ex) {
throw ex;
const type = ret.headers.get('content-type');
if(type && type.startsWith('application/json')) {
return await ret.json();
} else if(type && type.startsWith('text/')) {
return await ret.text();
}
return await ret.arrayBuffer();
}
}
`;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "http-modular",
"version": "0.1.0",
"version": "0.1.1",
"description": "A universal library for converting server-side functions into ES Modules.",
"main": "dist/es-modular.cjs",
"module": "src/index.js",
Expand Down
16 changes: 6 additions & 10 deletions src/modular.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ function makeRpc(url, func) {
'content-type': 'application/json'
}
});
try {
const type = ret.headers.get('content-type');
if(type && type.startsWith('application/json')) {
return await ret.json();
} else if(type && type.startsWith('text/')) {
return await ret.text();
}
return await ret.arrayBuffer();
} catch(ex) {
throw ex;
const type = ret.headers.get('content-type');
if(type && type.startsWith('application/json')) {
return await ret.json();
} else if(type && type.startsWith('text/')) {
return await ret.text();
}
return await ret.arrayBuffer();
}
}
`;
Expand Down

0 comments on commit 9e455b0

Please sign in to comment.