nonsensecreativity / dash
Kind of like LoDash but in PHP and lighter
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/nonsensecreativity/dash
Requires
- php: >=7.1
Requires (Dev)
- atoum/atoum: ^3.1
- atoum/stubs: ^2.5
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ^6.3
This package is not auto-updated.
Last update: 2025-09-28 05:35:34 UTC
README
Kind of Like LoDash but smaller
NOTE: Require at least PHP VERSION 7.1
Usage
composer require nonsensecreativity\dash
Import and call the lib static method
use function NSC\Dash\Iterables; /** * All iterable hook always provide * - The current value * - The current key * - The iterable set * * @param int $v * @param int $k * @param iterable $itr * @return iterable */ $flatMap = Iterables::flatMap([1, 2, 3, 4], function(int $v, int $k, iterable $itr) { return [$v + 1, $v]; });
or use via dash static method which will automatically redirecting the called method to proper class
use NSC\Dash\Dash; Dash::flatMapDeep( ['a', [ 'b', [ 'c', [ 'd' ] ] ] ], function(string $v, int $k, iterable $itr) { return [ $v, $v . ' FLATMAPDEEP' ]; } );
or use sequence
$seq = Sequence::from([1, [2, [3, [4, 5]]]]); $seq->flatten() ->reverse() ->flatMap(function($v, $k, $iterable) { return [$v, $v]; }) ->result();
TODO
- Add Test Case (some sample already added)
- More Functionality