You can have a linear workflow with the array functions.
The following is unreadable:
$output = array_reduce(
array_map(
function($n) { return $n ** 2; }
array_filter($input, function($n) { return $n % 2 == 0; })
),| node_modules/ | |
| .DS_Store |
| <?php | |
| if (! function_exists('take')) { | |
| /** | |
| * Run functions consecutively by piping through the result of one | |
| * into the next. | |
| * | |
| * @param mixed $value A value | |
| * | |
| * @return object | |
| */ |
| import React, { Component } from 'react' | |
| import { TransitionGroup, CSSTransition } from 'react-transition-group' | |
| import { | |
| BrowserRouter as Router, | |
| Switch, | |
| Route, | |
| Link, | |
| Redirect | |
| } from 'react-router-dom' |
| <?php | |
| use Slim\Http\Request; | |
| use Slim\Http\Response; | |
| use Slim\Http\Stream; | |
| $app->get('/stream', function (Request $request, Response $response, array $args) { | |
| // a 100mb file | |
| $path = '../public/files/document.pdf'; |
| node_modules | |
| dist |
| <?php | |
| final class User | |
| { | |
| private $name; | |
| public function __construct(string $name) | |
| { | |
| $this->name = $name; | |
| } |
| const defer = (res, ms) => new Promise(resolve => setTimeout(() => resolve(res), ms)); | |
| const makeDough = () => defer({add: () => {}}, 500); | |
| const makeSauce = () => defer({determineCheese: () => 'cheddar'}, 250); | |
| const grateCheese = () => defer({type: 'cheddar'}, 150); | |
| async function makePizza(sauceType = 'red') { | |
| const pDough = makeDough(); |
You can have a linear workflow with the array functions.
The following is unreadable:
$output = array_reduce(
array_map(
function($n) { return $n ** 2; }
array_filter($input, function($n) { return $n % 2 == 0; })
),| function translateError(msg) { | |
| var newErr = new Error(msg); // placed here to get correct stack | |
| return e => { | |
| newErr.originalError = e; | |
| throw newErr; | |
| } | |
| } | |
| async function asyncTask() { | |
| const user = await UserModel.findById(1).catch(translateError('No user found')) |
Not for everyone. Each programmer has their own appreciation of what is good coding music.
(From most influential to least)