Options
All
  • Public
  • Public/Protected
  • All
Menu

dmr-middleware

Language Build Status Coveralls npm package npm downloads

What's dmr-middleware

Features

Usage

API

Index

Type aliases

ConditionFn

ConditionFn: function

ConditionFn (index: string, value: string, _?) => boolean _ is underscore

Type declaration

    • (index: string, value: string, _?: any): boolean
    • Parameters

      • index: string
      • value: string
      • Optional _: any

      Returns boolean

FinisherLike

FinisherLike: "Gather" | "Noop"

A set of Finisher types that can be use in the next method in Config

可以在Config中的next方法中嵌套使用的Config类型集合

GatherCallback

GatherCallback: function

GatherCallback is a callback for processing. GatherCallback accepts Result | undefined.

GatherCallback为处理完毕时的回调, GatherCallback接受的参数为Result | undefined

Type declaration

    • Parameters

      Returns void

MiddlewareConfig

A set of Config types that can be nested in the next(and others) method in Config

可以在Config中的next类方法中嵌套使用的Config类型集合

ModifyFn

ModifyFn: function

ModifyFn (index: string, value: string, _?) => string | undefined; _ is underscore

Type declaration

    • (index: string, value: string, _?: any): string | undefined
    • Parameters

      • index: string
      • value: string
      • Optional _: any

      Returns string | undefined

Result

Result: [string, string]

The first item of the Result type is index, and the second item is value.

Result类型第一项为index, 第二项为value

Functions

MiddlewareFactory

  • MiddlewareFactory<T, S>(config: T): S
  • The factory method can accept MiddlewareConfig and return the generated middleware instance. MiddlewareFactory will automatically infer the type of the instance and return based on config

    Dmr-middleware的工厂方法可以接受MiddlewareConfig, 并返回生成的middleware实例 MiddlewareFactory会根据config自动推断实例的类型并返回.

    example
    
    const split =  MiddlewareFactory({_: "Split", separater: ",", next: "Gather"});
    split.handle("A,B,C,D", (result) => {console.log(result); });

    Type parameters

    Parameters

    • config: T

    Returns S