| @@ 434-442 (lines=9) @@ | ||
| 431 | * @param array $list |
|
| 432 | * @return array |
|
| 433 | */ |
|
| 434 | function insert() { |
|
| 435 | static $insert = false; |
|
| 436 | $insert = $insert ?: curry(function($position, $item, $list) { |
|
| 437 | return is_string($list) |
|
| 438 | ? insertAll($position, $item, $list) |
|
| 439 | : insertAll($position, [$item], $list); |
|
| 440 | }); |
|
| 441 | return _apply($insert, func_get_args()); |
|
| 442 | } |
|
| 443 | ||
| 444 | /** |
|
| 445 | * Same as `insert` but inserts an array instead of a single item. |
|
| @@ 307-314 (lines=8) @@ | ||
| 304 | * @param mixed $object |
|
| 305 | * @return mixed |
|
| 306 | */ |
|
| 307 | function update() { |
|
| 308 | static $update = false; |
|
| 309 | $update = $update ?: curry(function($name, $fn, $object) { |
|
| 310 | $value = get($name, $object); |
|
| 311 | return (null === $value) ? $object : set($name, $fn($value), $object); |
|
| 312 | }); |
|
| 313 | return _apply($update, func_get_args()); |
|
| 314 | } |
|
| 315 | ||
| 316 | /** |
|
| 317 | * Checks if an attribute/value of an object/array passes the given predicate. |
|