New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@onion-interceptor/pipes

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onion-interceptor/pipes - npm Package Compare versions

Comparing version 0.0.3-beta to 0.0.5-beta

26

dist/index.js
import { operate as r } from "onion-interceptor";
const w = (a) => r(async (c, t) => {
const w = (a) => r(async (o, t) => {
try {
await t();
} catch (c) {
throw c;
} finally {
a();
}
}), h = (a) => r(async (c, t) => {
}), h = (a) => r(async (o, t) => {
try {
await t();
} catch (o) {
throw a(o);
} catch (c) {
throw a(c);
}
}), i = (a) => r(async (c, t) => {
await new Promise((o) => setTimeout(o, a)), await t();
}), e = function(a, c, t) {
return r(async (o, s) => {
}), e = (a) => r(async (o, t) => {
await new Promise((c) => setTimeout(c, a)), await t();
}), i = function(a, o, t) {
return r(async (c, s) => {
try {
await s(), a(o);
await s(), a(c);
} catch (n) {
throw (c == null ? void 0 : c(n)) ?? n;
throw (o == null ? void 0 : o(n)) ?? n;
} finally {

@@ -29,5 +31,5 @@ t == null || t();

h as catchError,
i as delay,
e as delay,
w as finalize,
e as tap
i as tap
};
{
"name": "@onion-interceptor/pipes",
"version": "0.0.3-beta",
"version": "0.0.5-beta",
"type": "module",

@@ -33,5 +33,8 @@ "description": "onion-interceptor pipes",

"peerDependencies": {
"onion-interceptor": "latest"
"onion-interceptor": "0.0.5-beta"
},
"devDependencies": {
"onion-interceptor": "workspace:*"
},
"license": "ISC"
}

@@ -29,15 +29,17 @@ # @onion-interceptor/pipes

> 捕获错误
```typescript
import { catchError } from '@onion-interceptor/pipes'
import type { Next, Context } from 'onion-interceptor'
import { catchError } from "@onion-interceptor/pipes";
import type { Next, Context } from "onion-interceptor";
export async function errorInterceptor(ctx: Context, next: Next) {
console.log('errorInterceptor start', ctx)
console.log("errorInterceptor start", ctx);
await next(
catchError((err) => {
console.log(error)
return Promise.reject(error)
console.log(error);
return Promise.reject(error);
})
)
console.log('errorInterceptor end', ctx)
);
console.log("errorInterceptor end", ctx);
}

@@ -48,2 +50,4 @@ ```

> finalize 是一个操作管道,用于在请求或响应完成时执行一些操作(不管成功或失败)。
```typescript

@@ -61,17 +65,19 @@ import { finalize } from '@onion-interceptor/pipes'

> tap 是一个操作管道,可接受三个回调函数,后两个选填 分别为 成功后的回调,错误回调,无论成功还是失败都会执行的回调。
```typescript
import { tap } from '@onion-interceptor/pipes'
import { tap } from "@onion-interceptor/pipes";
export async function errorInterceptor(ctx: Context, next: Next) {
console.log('errorInterceptor start', ctx)
console.log("errorInterceptor start", ctx);
await next(
tap(
(_ctx) => console.log('find error in res', _ctx.res),
(_ctx) => console.log("find error in res", _ctx.res),
(error) => {
console.log(error)
return Promise.reject(error)
console.log(error);
return Promise.reject(error);
},
() => console.log('errorInterceptor end', ctx)
() => console.log("errorInterceptor end", ctx)
)
)
);
}

@@ -82,2 +88,4 @@ ```

> 延迟拦截器
```typescript

@@ -100,2 +108,2 @@ import type { Next, Context } from 'onion-interceptor'

本项目使用 MIT 许可证。
本项目使用 MIT 许可证。
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