@fatcherjs/middleware-json 3.0.0-alpha-10 → 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 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
@@ -1,6 +1,6 @@
1
1
  import { FatcherMiddleware } from 'fatcher';
2
2
 
3
- declare const json: () => FatcherMiddleware;
3
+ declare const json: FatcherMiddleware;
4
4
 
5
5
  declare module 'fatcher' {
6
6
  interface FatcherResponse {
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
- return async (context, next) => {
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
- return async (context, next) => {
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=()=>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 c="";await n(s.body,d=>{const u=o.decode(d,{stream:!0});c+=u,r==null||r(u,d)}),c+=o.decode(void 0,{stream:!1});try{return JSON.parse(c)}catch(d){return null}},e};t.json=f,Object.defineProperty(t,"__esModule",{value:!0})});
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-10"
16
+ "fatcher": "3.0.0-alpha-11"
17
17
  },
18
18
  "dependencies": {
19
- "@fatcherjs/utils-shared": "3.0.0-alpha-10"
19
+ "@fatcherjs/utils-shared": "3.0.0-alpha-11"
20
20
  },
21
21
  "devDependencies": {
22
- "fatcher": "3.0.0-alpha-10"
22
+ "fatcher": "3.0.0-alpha-11"
23
23
  },
24
- "version": "3.0.0-alpha-10",
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",