Socket
Socket
Sign inDemoInstall

@aomex/middleware

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aomex/middleware - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

24

CHANGELOG.md
# @aomex/middleware
## 0.0.3
## 0.0.4
### Patch Changes
- [`59ef917`](https://github.com/aomex/aomex/commit/59ef917533293301e8f3ab82460c8efc07df27c3) Thanks [@geekact](https://github.com/geekact)! - feat(middleware): chain.split 支持传递数组类型的分割点
- [`bbc8dda`](https://github.com/aomex/aomex/commit/bbc8dda9f0876c3402608133085350cc693def6f) Thanks [@geekact](https://github.com/geekact)! - refactor: rename package helper to utility
- Updated dependencies [[`146b6b5`](https://github.com/aomex/aomex/commit/146b6b5f09d4b9f557c1771686f3585bebf4cfc9)]:
- @aomex/helper@0.0.3
## 0.0.2
### Patch Changes
- [`e50ade9`](https://github.com/aomex/aomex/commit/e50ade9d85d02914d2a13b7e42c5ba09d277d2df) Thanks [@geekact](https://github.com/geekact)! - feat(middleware): base chain 设置为抽象类
- [`6a57463`](https://github.com/aomex/aomex/commit/6a57463c1107c38a8b8cf5fa00ff3289bf629c0a) Thanks [@geekact](https://github.com/geekact)! - refactor(middleware): 类型 MiddlewareFn 和 GetMiddlewareProps 迁移到命名空间
- [`6849b03`](https://github.com/aomex/aomex/commit/6849b03dc1e0dc9b707d89dfe98327c9f120dc7f) Thanks [@geekact](https://github.com/geekact)! - feat(middleware): chain.flatten 支持传入数组
## 0.0.1
### Patch Changes
- [`4f2dcad`](https://github.com/aomex/aomex/commit/4f2dcad3df59b7f2e3f2fb0ec31fbd56ddd7e098) Thanks [@geekact](https://github.com/geekact)! - 增加帮助类型 GetMiddlewareProps
- Updated dependencies [[`bbc8dda`](https://github.com/aomex/aomex/commit/bbc8dda9f0876c3402608133085350cc693def6f)]:
- @aomex/utility@0.0.4

25

dist/index.d.ts

@@ -10,3 +10,3 @@ interface _PureFn {

/**
* 创建纯粹的中间件,不含特殊上下文
* Pure middleware without context
*/

@@ -16,7 +16,7 @@ readonly pure: _PureFn;

declare namespace Middleware {
type Infer<T extends Middleware> = T extends Middleware<infer R> ? R : never;
type Infer<T> = T extends Middleware<infer R> ? R : T extends (...args: any[]) => Middleware<infer R> ? R : never;
type Fn<Ctx = any> = (ctx: Ctx, next: Next) => any;
}
/**
* 中间件基础类
* Base middleware
*/

@@ -28,3 +28,3 @@ declare abstract class Middleware<Props extends object = object> {

/**
* 注册创建中间件的快捷入口,比如:`middleware.pure()`
* Register middleware creator with specific context
*/

@@ -46,3 +46,3 @@ static register(platform: keyof MiddlewarePlatform, SubMiddleware: new (...args: any[]) => Middleware): void;

/**
* 创建纯粹的链条,不含特殊上下文
* pure middleware manager without context
*/

@@ -55,16 +55,13 @@ readonly pure: PureChain;

/**
* 注册快捷入口,比如`chain.pure`
* Register chain creator
*/
static register(platform: keyof ChainPlatform, SubChain: new (...args: any[]) => Chain): void;
/**
* 拍平任意链条、中间件和混合数组,并返回只包含中间件的数组
* Flatten mixed middleware and chain
*/
static flatten(middleware?: MiddleWareToken | null | Array<MiddleWareToken | null>): Middleware[];
static createSplitPoint(chain: Chain): string;
/**
* 创建分割点,并返回切割编号
* Split one chain to two chains, and returning last one
*/
static createPoint(chain: Chain): string;
/**
* 从分割点切割链条,并将后半段作为新的链条返回
*/
static split(chain: Chain, point?: string | string[]): Chain<object>;

@@ -75,3 +72,3 @@ protected readonly SubClass: new (middlewareList?: Middleware[]) => Chain;

/**
* 挂载中间件或者链条,并创建新的链条实例。在有条件判断的场景下,若无需执行某个中间件,传入`null`即可
* Mount a middleware or chain, input `null` for condition statement
*/

@@ -85,3 +82,3 @@ protected mount<P extends object>(middleware: MiddleWareToken<P> | null): Chain<Props & P>;

/**
* 把任意链条和中间件组合成一个符合`洋葱模型`的函数
* Compose middleware and chains
*/

@@ -88,0 +85,0 @@ declare const compose: (tokens: MiddleWareToken[]) => Compose;

@@ -9,3 +9,3 @@ var __defProp = Object.defineProperty;

// src/chain.ts
import { toArray } from "@aomex/helper";
import { toArray } from "@aomex/utility";
var _Chain = class {

@@ -17,3 +17,3 @@ constructor(middlewareList = []) {

/**
* 注册快捷入口,比如`chain.pure`
* Register chain creator
*/

@@ -28,3 +28,3 @@ static register(platform, SubChain) {

/**
* 拍平任意链条、中间件和混合数组,并返回只包含中间件的数组
* Flatten mixed middleware and chain
*/

@@ -40,6 +40,3 @@ static flatten(middleware2) {

}
/**
* 创建分割点,并返回切割编号
*/
static createPoint(chain2) {
static createSplitPoint(chain2) {
const point = "point_" + ++this.autoIncrementID;

@@ -50,3 +47,3 @@ chain2.points[point] = chain2.middlewareList.length;

/**
* 从分割点切割链条,并将后半段作为新的链条返回
* Split one chain to two chains, and returning last one
*/

@@ -63,3 +60,3 @@ static split(chain2, point = []) {

/**
* 挂载中间件或者链条,并创建新的链条实例。在有条件判断的场景下,若无需执行某个中间件,传入`null`即可
* Mount a middleware or chain, input `null` for condition statement
*/

@@ -85,3 +82,3 @@ mount(middleware2) {

if (i <= lastIndex) {
throw new Error("next()\u88AB\u6267\u884C\u591A\u6B21");
throw new Error("call next() multiple times");
}

@@ -102,3 +99,3 @@ const fn = i === middlewareList.length ? next : middlewareList[i].fn;

/**
* 注册创建中间件的快捷入口,比如:`middleware.pure()`
* Register middleware creator with specific context
*/

@@ -105,0 +102,0 @@ static register(platform, SubMiddleware) {

{
"name": "@aomex/middleware",
"version": "0.0.3",
"description": "",
"version": "0.0.4",
"description": "Middleware, manager-chain and compose",
"type": "module",

@@ -27,5 +27,5 @@ "types": "dist/index.d.ts",

"dependencies": {
"@aomex/helper": "^0.0.3"
"@aomex/utility": "^0.0.4"
},
"scripts": {}
}

Sorry, the diff of this file is not supported yet

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