Skip to content

Commit 08197c0

Browse files
committed
Compile new functions
1 parent 16f9a04 commit 08197c0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/compiled.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@
133133
namespace _\internal { function baseIndexOfWith(array $array, $value, int $fromIndex, $comparator) { $index = $fromIndex - 1; foreach (\array_slice($array, $fromIndex, null, true) as $val) { ++$index; if ($comparator($val, $value)) { return $index; } } return -1; } }
134134
namespace _\internal { function baseReduce(iterable $array, $iteratee, $accumulator, $initAccum = null) { $length = \is_array($array) || $array instanceof \Countable ? \count($array) : 0; if ($initAccum && $length) { $accumulator = \current($array); } foreach ($array as $key => $value) { $accumulator = $iteratee($accumulator, $value, $key, $array); } return $accumulator; } }
135135
namespace _ { interface CacheInterface { public function set($key, $value): CacheInterface; public function get($key); public function has($key): bool; public function clear(); public function delete($key); public function getSize(); } }
136+
namespace _ { use function _\internal\arrayMap; use function _\internal\baseFlatten; use function _\internal\baseRest; use function _\internal\baseUnary; function overArgs(callable $func, array $transforms): callable { return baseRest(function ($func, $transforms) { $transforms = (count($transforms) == 1 && \is_array($transforms[0])) ? arrayMap($transforms[0], baseUnary('\_\internal\baseIteratee')) : arrayMap(baseFlatten($transforms, 1), baseUnary('\_\internal\baseIteratee')); $funcsLength = \count($transforms); return baseRest(function (...$args) use ($funcsLength, $transforms, $func) { $index = -1; $length = \min(\count($args), $funcsLength); while (++$index < $length) { $args[$index] = $transforms[$index]($args[$index]); } return $func(...$args); }); })($func, $transforms); } }
137+
namespace _ { function before(int $n, callable $func): callable { $result = null; return function (...$args) use (&$result, &$n, &$func) { if (--$n > 0) { $result = $func(...$args); } return $result; }; } }
138+
namespace _ { function ary(callable $func, int $n): callable { return function (...$args) use ($func, $n) { \array_splice($args, $n); return $func(...$args); }; } }
139+
namespace _ { function once(callable $func): callable { return before(2, $func); } }
136140
namespace _ { function after(int $n, callable $func): callable { return function (...$args) use (&$n, $func) { if (--$n < 1) { return $func(...$args); } }; } }
137141
namespace _ { function negate(callable $predicate): callable { return function () use ($predicate) { return !$predicate(...\func_get_args()); }; } }
138142
namespace _ { function memoize(callable $func, callable $resolver = null) { $memoized = new class($func, $resolver ?? null) { public $cache; private $resolver; private $func; public function __construct(callable $func, ?callable $resolver) { $this->resolver = $resolver; $this->func = $func; } public function __invoke() { $args = \func_get_args(); if ($this->resolver) { $key = \Closure::fromCallable($this->resolver)->bindTo($this)(...$args); } else { $key = &$args[0]; } $cache = $this->cache; if ($cache->has($key)) { return $cache->get($key); } $result = ($this->func)(...$args); $this->cache = $this->cache->set($key, $result); return $result; } }; $memoized->cache = new MapCache; return $memoized; } }

0 commit comments

Comments
 (0)