/** biome-ignore-all lint/suspicious/noExplicitAny: <> */ import type { As, Shunt } from '@chzky/core'; type Shunter = Shunt; /** ## `intercept` : 用于快速进行`截流`的`MiddleWare` + 用于配合`pipe`等函数进行`快速截流`操作 , 用于期望整体结果返回 `Monad` 类型的场景 : 1. 针对可转化成`Mainstream`的类型 : + `As,'shunt'>` --> `Shunt` 2. 针对可转化成`Reflux`的类型 : + `As,'shunt'>` --> `Shunt` @example Usage - with pipe ```ts const result = pipe( 'xx' as const, // 'xx' x => Ok(x), // Ok('xx') intercept // 'xx' ) assert.equal(result, 'xx') const result_o = pipe( 'xx' as const, // 'xx' x => Err(x), // Err('xx') intercept // Err('xx') ) assert.equal(result_o, Err('xx')) ``` @example Usage - with flow ```ts const mock_io_operations = (path: string) => { if (path === 'mod.ts') return NotFoundError.err('path is not found') return Ok({ size: 1024 * 1024 * 3 }) } const size_exchange = (size: number) => { const dd = size / 1024 / 1024 if (dd % 2 !== 0) return UnexpectedError.err('size is not qualified') return Ok(dd) } const process: Result = pipe.sync( 'mod.ts', // string mock_io_operations, // Result<{size:number},NotFoundError> intercept, // Shunt<{size:number},Err(NotFoundError)> --> Possible Direct Return NotFoundError take('size'), // {size:number} --> number size_exchange // Result ) assert(process.unwrap_err().instance_of(NotFoundError)) ``` @category MiddleWare */ export declare const intercept: >(interceptable: T) => T extends As ? O extends "shunt" ? I extends Shunter ? I extends Shunt ? Shunt : I extends Shunt ? Shunt : never : never : never : never; export {}; //# sourceMappingURL=intercept.d.ts.map