@fatcherjs/middleware-json 3.0.0-alpha-9 → 3.0.0-alpha-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +5 -3
- package/dist/index.js +5 -3
- package/dist/index.min.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ import { fatcher } from 'fatcher';
|
|
|
25
25
|
import { json } from '@fatcherjs/middleware-json';
|
|
26
26
|
|
|
27
27
|
const res = await fatcher('https://foo.bar/get', {
|
|
28
|
-
middlewares: [json
|
|
28
|
+
middlewares: [json],
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
const streamingJson = await res.readStreamAsJson((string: string, buffer: Uint8Array) => {
|
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { readStreamByChunk } from '@fatcherjs/utils-shared';
|
|
2
|
+
import 'fatcher';
|
|
2
3
|
|
|
3
|
-
const json =
|
|
4
|
-
|
|
4
|
+
const json = {
|
|
5
|
+
name: "fatcher-middleware-json",
|
|
6
|
+
use: async (context, next) => {
|
|
5
7
|
const response = await next();
|
|
6
8
|
if (response.bodyUsed || !response.body) {
|
|
7
9
|
response.readStreamAsJson = async () => null;
|
|
@@ -24,7 +26,7 @@ const json = () => {
|
|
|
24
26
|
}
|
|
25
27
|
};
|
|
26
28
|
return response;
|
|
27
|
-
}
|
|
29
|
+
}
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
export { json };
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var utilsShared = require('@fatcherjs/utils-shared');
|
|
6
|
+
require('fatcher');
|
|
6
7
|
|
|
7
|
-
const json =
|
|
8
|
-
|
|
8
|
+
const json = {
|
|
9
|
+
name: "fatcher-middleware-json",
|
|
10
|
+
use: async (context, next) => {
|
|
9
11
|
const response = await next();
|
|
10
12
|
if (response.bodyUsed || !response.body) {
|
|
11
13
|
response.readStreamAsJson = async () => null;
|
|
@@ -28,7 +30,7 @@ const json = () => {
|
|
|
28
30
|
}
|
|
29
31
|
};
|
|
30
32
|
return response;
|
|
31
|
-
}
|
|
33
|
+
}
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
exports.json = json;
|
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t,n){typeof exports=="object"&&typeof module!="undefined"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(t=typeof globalThis!="undefined"?globalThis:t||self,n(t.FatcherMiddlewareJson={}))})(this,function(t){"use strict";async function n(i,a){async function e(s){const{value:r,done:o}=await s.read();o||(await a(r),await e(s))}return e(i.getReader())}const f=
|
|
1
|
+
(function(t,n){typeof exports=="object"&&typeof module!="undefined"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(t=typeof globalThis!="undefined"?globalThis:t||self,n(t.FatcherMiddlewareJson={}))})(this,function(t){"use strict";async function n(i,a){async function e(s){const{value:r,done:o}=await s.read();o||(await a(r),await e(s))}return e(i.getReader())}const f={name:"fatcher-middleware-json",use:async(i,a)=>{const e=await a();if(e.bodyUsed||!e.body)return e.readStreamAsJson=async()=>null,e;const s=e.clone();return e.readStreamAsJson=async r=>{const o=new TextDecoder;let d="";await n(s.body,c=>{const u=o.decode(c,{stream:!0});d+=u,r==null||r(u,c)}),d+=o.decode(void 0,{stream:!1});try{return JSON.parse(d)}catch(c){return null}},e}};t.json=f,Object.defineProperty(t,"__esModule",{value:!0})});
|
package/package.json
CHANGED
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"fatcher": "3.0.0-alpha-
|
|
16
|
+
"fatcher": "3.0.0-alpha-11"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@fatcherjs/utils-shared": "3.0.0-alpha-
|
|
19
|
+
"@fatcherjs/utils-shared": "3.0.0-alpha-11"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"fatcher": "3.0.0-alpha-
|
|
22
|
+
"fatcher": "3.0.0-alpha-11"
|
|
23
23
|
},
|
|
24
|
-
"version": "3.0.0-alpha-
|
|
24
|
+
"version": "3.0.0-alpha-11",
|
|
25
25
|
"scripts": {
|
|
26
26
|
"clean": "rimraf dist",
|
|
27
27
|
"build": "npm run clean && rollup -c rollup.config.ts",
|