Skip to content

Commit

Permalink
Revert "Adds once memoization function (#550)"
Browse files Browse the repository at this point in the history
This reverts commit dd09c55010281dc0ed82ab0f116397e086af5d68.
  • Loading branch information
huangdijia committed Feb 4, 2024
1 parent a57b9d1 commit 509c660
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 201 deletions.
18 changes: 0 additions & 18 deletions src/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,3 @@ function retry($times, callable $callback, $sleepMilliseconds = 0, $when = null)
goto beginning;
}
}

/**
* Ensures a callable is only called once, and returns the result on subsequent calls.
*
* @template TReturnType
*
* @param callable(): TReturnType $callback
* @return TReturnType
*/
function once(callable $callback)
{
$onceable = Onceable::tryFromTrace(
debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2),
$callback,
);

return $onceable ? Once::instance()->value($onceable) : call_user_func($callback);
}
98 changes: 0 additions & 98 deletions src/Once.php

This file was deleted.

85 changes: 0 additions & 85 deletions src/Onceable.php

This file was deleted.

0 comments on commit 509c660

Please sign in to comment.