Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aceworks-studio/time

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aceworks-studio/time

A set of utility functions around time

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

checks version GitHub top language license npm

@aceworks-studio/time

A set of utility functions around time.

Installation

Add @aceworks-studio/time in your dependencies:

yarn add @aceworks-studio/time

Or if you are using npm:

npm install @aceworks-studio/time

Content

debounce

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.

loopUntil

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.

loopWhile

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.

noYield

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.

throttle

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.

yieldUntil

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.

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).

License

This project is available under the MIT license. See LICENSE.txt for details.

Other Lua Environments Support

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.

Keywords

FAQs

Package last updated on 04 Jun 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc