Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@aceworks-studio/time
Advanced tools
A set of utility functions around time.
Add @aceworks-studio/time
in your dependencies:
yarn add @aceworks-studio/time
Or if you are using npm
:
npm install @aceworks-studio/time
function debounce<R, T...>(durationSeconds: number, fn: (T...) -> R): (T...) -> R?
Returns a debounced version of the provided function that skips the execution until the given amount of time have elapsed since the last time it was invoked.
If durationSeconds
is less than or equal to 0, the given function is simply returned.
function loopUntil(interval: Interval, fn: (deltaTime: number) -> boolean): () -> ()
Continuously calls a function at specified intervals until a condition is met or an optional timeout is reached. The timeout can be provided using the interval type.
Returns a function that cancel the loop.
function loopWhile(interval: Interval, fn: (deltaTime: number) -> boolean): () -> ()
Continuously calls a function at specified intervals while a condition is met. An optional timeout can be be provided using the interval type.
Returns a function that cancel the loop.
function noYield<T..., R...>(fn: (T...) -> R..., ...: T...): R...
Executes a function ensuring that it does not yield. If the function attempts to yield, an error is thrown. This is particularly useful in development environments to enforce non-yielding behavior.
function throttle<R..., T...>(durationSeconds: number, fn: (T...) -> R...): (T...) -> ()
Returns a throttled version of the provided function that only allows it to be called at most once every durationSeconds
.
If the function is called more frequently, the calls are delayed until the duration has passed.
function yieldUntil(interval: Interval, fn: (deltaTime: number) -> boolean)
Yields the current coroutine until a specified condition is met, checking the condition at regular intervals specified by interval
. Continues to yield and check the condition until it is met or an optional timeout is reached.
The timeout can be provided using the interval type.
type Interval = number | { interval: number, duration: number? }
The exported type Interval
is used to provide a time interval in seconds with an optional maximum duration (in seconds too).
This project is available under the MIT license. See LICENSE.txt for details.
If you would like to use this library on a Lua environment where it is currently incompatible, open an issue (or comment on an existing one) to request the appropriate modifications.
The library uses darklua to process its code.
FAQs
A set of utility functions around time
The npm package @aceworks-studio/time receives a total of 1 weekly downloads. As such, @aceworks-studio/time popularity was classified as not popular.
We found that @aceworks-studio/time demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.