justjohn/twig.js — pull request #163 by jmealo (2014-06-11 02:08:02+00:00)
Title: Compatible Approach: Implemented min and max functions

**I'll preface this PR with this:**
The behavior of PHP's ``min`` and ``max`` functionals when passed associative arrays is ... *interesting*.

Regrettably, I've included the ``max`` and ``min`` functions from phpjs to ensure full compatibility. (The ``max`` and ``min`` functions are 90% similar and very long for what they do.)

There's much better ways to implement this using native ``Array.sort()`` and ``Math.max()`` and ``Math.min()``... however, the result doesn't behave as ``min`` and ``max``, so it won't pass the unit tests.

I didn't hack apart ``min`` and ``max`` to save a few bytes as gzip will take care of this. I would like to revisit any phpjs code we include to see if we can optimize some of the common code re-used between snippets.