GithubHelp home page GithubHelp logo

underscore-1's Introduction

Underscore

Build Status Scrutinizer Quality Score Code Coverage SensioLabsInsight

Functional programming library for PHP

Code example

Library aims to be as easy to use as possible. Here is example of doing some not-so-meaningful operations to show off:

    Underscore::from([1,2,3,4,5])
            // convert array format
        ->map(function($num) { return ['number' => $num];})
            // filter out odd elements
        ->filter(function($item) { return ($item['number'] % 2) == 0;})
            // vardump elements
        ->invoke(function($item) { var_dump($item);})
            // changed my mind, I only want numbers
        ->pick('number')
            // add numbers to 1000
        ->reduce(function($sum, $num) { $sum += $num; return $sum; }, 1000)
            // take result
        ->value();
            // 1006

Motivation

Originaly I needed functional programming magic for other project, so had to pick one lib or write my own.

There is several PHP ports of UnderscoreJS, however none of those fit my requirements (nice code, easy to write, standardized):

Installation

Via composer:

$ composer require Im0rtality/Underscore:dev-master

Composer docs recommend to use specific version. You can look them up in Releases.

Documentation

Will be added later

TODO

Check open issues

Tests

Each commit is tested on TRAVIS using multiple PHP versions (5.3, 5.4, 5.5; plus 5.6, hhvm which are being run but not checked for failures) to ensure compatibility.

Tests generate coverage reports in clover.xml format

$ phpunit

License

MIT License: You can do whatever you want as long as you include the original copyright.

underscore-1's People

Contributors

im0rtality avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.