pitchart/transformer
Composer 安装命令:
composer require pitchart/transformer
包简介
A transducers implementation in PHP, with OOP powers
README 文档
README
A transducers implementation in PHP, with OOP powers
This package has been inspired by libraries provided by other languages, like clojure's transducers or JAVA Stream API.
Why ?
Transducers are composable algorithmic transformations. They are independent from the context of their input and output sources and specify only the essence of the transformation in terms of an individual element. Because transducers are decoupled from input or output sources, they can be used in many different processes - collections, streams, channels, observables, etc. Transducers compose directly, without awareness of input or creation of intermediate aggregates.
More information on the clojure reference
With classical pipeline pattern, the whole collection is iterated for each step of the transformation and creates an intermediate collection which is a massive waste in memory usage.
Transducers use functional composition to reduce the number of iterations made while applying transformation.
Installation
composer require pitchart/transformer
Usage
A transformation consists in a pipeline of transformation functions, called Reducers, ended by a reducing function, aka Termination.
use function Pitchart\transform; transform([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) ->filter(function (int $integer) { return $integer % 2 === 0;}) // [0, 2, 4, 6, 8, 8, 6, 4, 2, 0] ->map(function (int $integer) { return $integer + 1; }) // [1, 3, 5, 7, 9, 9, 7, 5, 3, 1] ->dedupe() // [1, 3, 5, 7, 9, 9, 7, 5, 3, 1] ->distinct() // [1, 3, 5, 7, 9] ->take(3) // [1, 3, 5] ->sum() // 9 ;
API documentation
"Functional patterns" used by the library are discribed in the Reducers documentation
Credits
Licence
The MIT License (MIT). See License file for more information.
pitchart/transformer 适用场景与选型建议
pitchart/transformer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.96k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2017 年 07 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「collection」 「composition」 「functional programming」 「iterable」 「transducer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pitchart/transformer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pitchart/transformer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pitchart/transformer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Connection 'Db' codeception module to 'Yii2' module database settings
Functional programming utilities for composing, decorating, and controlling function execution
Function composition.
Functional library for php with proper currying
Iteration tools for PHP
This package provides type-safe extension of the laravel collection, forcing a single type of object.
统计信息
- 总下载量: 16.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 15
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-05