bcen/yauc
最新稳定版本:0.0.8
Composer 安装命令:
composer require bcen/yauc
包简介
Yet Another Underscore Clone
关键字:
README 文档
README
Usage
Chainable:
use Yauc\Underscore as _;
$stooges = array(
array(
'name' => 'curl',
'age' => 25
),
array(
'name' => 'moe',
'age' => 21
),
array(
'name' => 'larry',
'age' => 23
)
);
// 'curl is 25'
_::chain($stooges)
->map(function($item) { return $item['name'] . ' is ' . $item['age'];})
->first()
->value();
OOP non-chain mode:
$mapped = _::init($stooges)->map(function($item) { return $item['name'] . ' is ' . $item['age'];});
$first = _::init($mapped)->first();
OOP-static call:
_::first(_::map($this->stooges, function($item) {
return $item['name'] . ' is ' . $item['age'];
}));
Functional:
_first(_map($stooges, function($item) {
return $item['name'] . ' is ' . $item['age'];
}));
Hybrid:
_::init($stooges)
->makeChain()
->filter(...)
->map(...)
->pluck(...)
->disableChain()
->first()
Method Delegate
The implementation of map is too slow? or the pluck is not plucking? No problem!
class MyMethodDelegate extends \Yauc\Delegate\UnderscoreMethodDelegate
{
public static function map($item, $iterator)
{
// ...
}
}
_::setMethodDelegate('MyMethodDelegate');
_::chain($stooges)
->map(function($item) { return $item['name'] . ' is ' . $item['age'];})
->first()
->value();
统计信息
- 总下载量: 133
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-12-05