diff --git a/README.md b/README.md index 34fee57..6f10d9f 100644 --- a/README.md +++ b/README.md @@ -9,30 +9,6 @@ Pipeline comes with the most important yet basic building blocks. It boasts meth This rigorously tested library just works. Pipeline never throws any exceptions. -# Entry points - -All entry points always return an instance of a standard pipeline. - -| Method | Details | -| ----------- | ----------------------------- | -| `map()` | Takes an optional initial callback, where it must not require any arguments. Other than that, works just like an instance method below. | -| `take()` | Takes any Traversable, initializes a standard pipeline with it. | -| `fromArray()` | Takes an array, initializes a standard pipeline with it. | - -# Instance methods in a nutshell - -| Method | Details | A.K.A. | -| ----------- | ----------------------------- | ----------------- | -| `map()` | Takes an optional callback that for each input value may return one or yield many. Also takes an initial generator, where it must not require any arguments. Provided no callback does nothing. Also available as a plain function. | `array_map`, `Select`, `SelectMany` | -| `unpack()` | Unpacks arrays into arguments for a callback. Flattens inputs if no callback provided. | `flat_map`, `flatten` | -| `filter()` | Removes elements unless a callback returns true. Removes falsey values if no callback provided. | `array_filter`, `Where` | -| `reduce()` | Reduces input values to a single value. Defaults to summation. | `array_reduce`, `Aggregate`, `Sum` | -| `toArray()` | Returns an array with all values. Eagerly executed. | `dict`, `ToDictionary` | -| `__construct()` | Can be provided with an optional initial iterator. Used in the `take()` function from above. Not part of any interface. | | - -Pipeline is an iterator and can be used as any other iterable. Implements `JsonSerializable`. - -Pipeline is a final class. It comes with a pair of interfaces to aid you with [composition over inheritance](https://stackoverflow.com/questions/30683432/inheritance-over-composition). # Install @@ -94,6 +70,31 @@ var_dump($value); // int(104) ``` +# API entry points + +All entry points always return an instance of a standard pipeline. + +| Method | Details | Use with | +| ----------- | ----------------------------- | ----------- | +| `map()` | Takes an optional initial callback, where it must not require any arguments. Other than that, works just like an instance method below. | `use function Pipeline\map;` | +| `take()` | Takes any Traversable, initializes a standard pipeline with it. | `use function Pipeline\take;` | +| `fromArray()` | Takes an array, initializes a standard pipeline with it. | `use function Pipeline\fromArray;` | + +# Instance methods in a nutshell + +| Method | Details | A.K.A. | +| ----------- | ----------------------------- | ----------------- | +| `map()` | Takes an optional callback that for each input value may return one or yield many. Also takes an initial generator, where it must not require any arguments. Provided no callback does nothing. Also available as a plain function. | `array_map`, `Select`, `SelectMany` | +| `unpack()` | Unpacks arrays into arguments for a callback. Flattens inputs if no callback provided. | `flat_map`, `flatten` | +| `filter()` | Removes elements unless a callback returns true. Removes falsey values if no callback provided. | `array_filter`, `Where` | +| `reduce()` | Reduces input values to a single value. Defaults to summation. | `array_reduce`, `Aggregate`, `Sum` | +| `toArray()` | Returns an array with all values. Eagerly executed. | `dict`, `ToDictionary` | +| `__construct()` | Can be provided with an optional initial iterator. Used in the `take()` function from above. Not part of any interface. | | + +Pipeline is an iterator and can be used as any other iterable. Implements `JsonSerializable`. + +Pipeline is a final class. It comes with a pair of interfaces to aid you with [composition over inheritance](https://stackoverflow.com/questions/30683432/inheritance-over-composition). + # Caveats - Since most callback are [lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) as more data coming in and out, you must consume the results with a plain `foreach` or use a `reduce()` to make sure processing happens.