| @@ 412-420 (lines=9) @@ | ||
| 409 | * @param array $list |
|
| 410 | * @return array |
|
| 411 | */ |
|
| 412 | function insert() { |
|
| 413 | static $insert = false; |
|
| 414 | $insert = $insert ?: curry(function($position, $item, $list) { |
|
| 415 | return (is_string($list)) |
|
| 416 | ? insertAll($position, $item, $list) |
|
| 417 | : insertAll($position, [$item], $list); |
|
| 418 | }); |
|
| 419 | return _apply($insert, func_get_args()); |
|
| 420 | } |
|
| 421 | ||
| 422 | /** |
|
| 423 | * Same as `insert` but inserts an array instead of a single item. |
|
| @@ 301-308 (lines=8) @@ | ||
| 298 | * @param mixed $object |
|
| 299 | * @return mixed |
|
| 300 | */ |
|
| 301 | function update() { |
|
| 302 | static $update = false; |
|
| 303 | $update = $update ?: curry(function($name, $fn, $object) { |
|
| 304 | $value = get($name, $object); |
|
| 305 | return (null === $value) ? $object : set($name, $fn($value), $object); |
|
| 306 | }); |
|
| 307 | return _apply($update, func_get_args()); |
|
| 308 | } |
|
| 309 | ||
| 310 | /** |
|
| 311 | * Checks if an attribute/value of an object/array passes the given predicate. |
|