2017 © Pedro Peláez
 

library dash

Kind of like LoDash but in PHP and lighter

image

nonsensecreativity/dash

Kind of like LoDash but in PHP and lighter

  • Sunday, August 20, 2017
  • by nonsensecreativity
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

DASH

Kind of Like LoDash but smaller, (*1)

NOTE: Require at least PHP VERSION 7.1, (*2)

Usage

composer require nonsensecreativity\dash, (*3)

Import and call the lib static method, (*4)

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, (*5)

use NSC\Dash\Dash;

Dash::flatMapDeep(
    ['a', [ 'b', [ 'c', [ 'd' ] ] ] ],
    function(string $v, int $k, iterable $itr) {
        return [ $v, $v . ' FLATMAPDEEP' ];
    }
);

or use sequence, (*6)

$seq = Sequence::from([1, [2, [3, [4, 5]]]]);
$seq->flatten()
    ->reverse()
    ->flatMap(function($v, $k, $iterable) {
        return [$v, $v];
    })
    ->result();

TODO, (*7)

  • [ ] Add Test Case (some sample already added)
  • [ ] More Functionality

The Versions

20/08 2017

dev-master

9999999-dev

Kind of like LoDash but in PHP and lighter

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Hermanto Lim