Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

Alternative to underscore-php #105

@mpetrovich

Description

@mpetrovich

Frustrated by the lack of updates, we built our own Underscore-like functional programming library since none of the tools out there were maintained, easy to use, or well-documented: https://github.com/nextbigsoundinc/dash

$avgMaleAge = Dash\chain([
	['name' => 'John', 'age' => 12, 'gender' => 'male'],
	['name' => 'Jane', 'age' => 34, 'gender' => 'female'],
	['name' => 'Pete', 'age' => 23, 'gender' => 'male'],
	['name' => 'Mark', 'age' => 11, 'gender' => 'male'],
	['name' => 'Mary', 'age' => 42, 'gender' => 'female'],
])
->filter(['gender', 'male'])
->map('age')
->average()
->value();

echo "Average male age is $avgMaleAge.";

Highlights:

  • Many data types supported: arrays, objects, generators (coming soon), Traversable, DirectoryIterator, and more
  • Chaining
  • Currying
  • Lazy evaluation
  • Custom operations
  • Well-tested: Comprehensive tests with nearly 3,000 test cases and 100% code coverage

I hope it can be useful to someone. Feedback welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions