ericpoe / haystack Goto Github PK
View Code? Open in Web Editor NEWForget Haystack vs Needle order, the object IS the Haystack. Haystack is a library that allows for pipelining and immutable structures.
License: MIT License
Forget Haystack vs Needle order, the object IS the Haystack. Haystack is a library that allows for pipelining and immutable structures.
License: MIT License
Supplying the $flag
parameter to FunctionalInterface::filter(callable $func = null, $flag = null);
currently relies on PHP 5.6 constants \USE_KEY
and \USE_BOTH
to decide whether the callback is called with the value, key or both <value, key>. This functionality should instead be available for all PHP versions supported via composer.json require statement, currently >= 5.5.9.
I see two possible approaches here...
1) Haystack adds its own constants and uses them for filter($func, null $flag = null)
.
null
- Pass value.FunctionalInterface::USE_KEY
- Pass key.FunctionalInterface::USE_BOTH
- Pass both.2) Haystack adds two new methods that don't require calling code to provide the flags.
filter($func, null $flag = null)
-- Passes container value to callback unless $flag given. $flag can be one of null || FunctionalInterface::USE_KEY || FunctionalInterface::USE_BOTH
. Return true preserves key => value in new container.filterByKey($func)
-- Passes container key to callback. Implementation delegates to filter() and supplies the correct constant. Return true preserves key => value in new container.filterByBoth($func)
-- Passes container key as first callback argument, value as second argument. Implementation delegates to filter() and supplies the correct constant. Return true preserves key => value in new container.As PHP has completely dropped support for both 5.6 and 7.0, the library should stay current and move up to 7.1 as a minimum since its the lowest supported version.
Great job on this project. This is a big need in the PHP world.
I'm having a bit of a hard time agreeing that the tail() method is named properly. On at first glance I expected tail to give me the last element of a collection and not everything but the head. I equated it to the unix tail command which (by default) gives you the last 10 lines of a file. Is there a precedent in other languages for a tail() method to do as this project does now?
Drupal 8 has a minimum requirement of PHP >= 5.5.9. Drupal developers may be unable to use Haystack if their host only provides the minimum PHP version. Given Drupal's wide appeal could we consider lowering Haystack's minimum requirements to PHP 5.5.9+?
Moving from PHP 5.4 to 5.6 started here: 4a62a0d
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.