
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Helper functions for implementing the idle-until-urgent pattern. For detailed explanation of this pattern, see this article from Philip Walton.
// with yarn
yarn add idley
// with npm
npm install idley
// ES2015+ and TS
import { computed, throttled, debounced } from 'idley'
// CommonJS
var idley = require('idley')
computed(fn: function): function
Creates a function that returns the result of executing the passed fn
when the browser is idle. If the result is requested and it has not been computed yet, the function will be executed immediately.
const { computed } from 'idely'
const heavyTask = () => 5
const foo = computed(heavyTask)
console.log(foo()) // 5
throttled(fn: function): function
Creates a throttled function that only invokes the passed fn
at most once when the browser is idle.
const { throttled } from 'idely'
const heavyTask = (n) => console.log(n)
const foo = throttled(heavyTask)
foo(1)
foo(2)
// 2
debounced(fn: function): function
Creates a debounced function that delays invoking the passed fn
until the browser is idle.
const { debounced } from 'idely'
const heavyTask = (n) => console.log(n)
const foo = debounced(heavyTask)
foo(1)
foo(2)
// 1
// 2
This library relies on requestIdleCallback. It will degrade to requestAnimationFrame, or setTimeout in this order
Published under MIT Licence
(c) Yosbel Marin 2018
FAQs
Helper functions for implementing the idle-until-urgent pattern
The npm package idley receives a total of 4 weekly downloads. As such, idley popularity was classified as not popular.
We found that idley demonstrated a not healthy version release cadence and project activity because the last version was released 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.