Metadata-Version: 2.5
Name: iifunc
Version: 0.0.3
Summary: Compose functions into a pipeline, right to left or left to right.
Project-URL: Homepage, https://pypi.org/project/iifunc/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: compose,functional,higher-order,pipe,pipeline
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# iifunc

[English](#english) | 中文

把普通函数组合成管道，不需要类或框架。

## 安装

```console
pip install iifunc
```

## 用法

```python
from iifunc import compose, pipe

def double(x): return x * 2
def bump(x): return x + 1

pipe(double, bump)(3)      # bump(double(3)) == 7
compose(double, bump)(3)   # double(bump(3)) == 8
pipe()(5)                  # 5

clean = pipe(str.strip, str.lower)
clean("  ABC  ")           # 'abc'
```

## 说明

`pipe` 从左到右（`g(f(x))`），`compose` 从右到左（`f(g(x))`）；不传参数返回恒等函数，生成的管道不用特判空列表。额外实参只给**第一个**被调用的函数，后续每级只收一个值。

## 许可证

MIT

---

<a id="english"></a>
## English

Compose functions into a pipeline, right to left or left to right.

## Install

```console
pip install iifunc
```

## Usage

```python
from iifunc import compose, pipe

def double(x): return x * 2
def bump(x): return x + 1

pipe(double, bump)(3)      # bump(double(3)) == 7
compose(double, bump)(3)   # double(bump(3)) == 8
pipe()(5)                  # 5

clean = pipe(str.strip, str.lower)
clean("  ABC  ")           # 'abc'
```

## Notes

`pipe` reads left to right (`g(f(x))`), `compose` right to left (`f(g(x))`). No arguments gives the identity function. Extra arguments go only to the first function; later stages take exactly one value.

## License

MIT
