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

@solid-primitives/scheduled

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/scheduled - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

dist/index.d.cts

42

dist/index.js

@@ -84,4 +84,3 @@ import { getOwner, onCleanup, createSignal, getListener } from 'solid-js';

let isScheduled = false;
const onTrail = () => isScheduled = false;
const scheduled = schedule(onTrail, wait);
const scheduled = schedule(() => isScheduled = false, wait);
const func = (...args) => {

@@ -112,24 +111,23 @@ if (!isScheduled)

}
const LEADING = 0;
const TRAILING = 1;
const RESET = 2;
let firstCall = true;
const onTrail = (callType, args) => {
if (callType === RESET) {
firstCall = true;
return;
let State;
((State2) => {
State2[State2["Ready"] = 0] = "Ready";
State2[State2["Leading"] = 1] = "Leading";
State2[State2["Trailing"] = 2] = "Trailing";
})(State || (State = {}));
let state = 0 /* Ready */;
const scheduled = schedule((args) => {
state === 2 /* Trailing */ && callback(...args);
state = 0 /* Ready */;
}, wait);
const fn = (...args) => {
if (state !== 2 /* Trailing */) {
if (state === 0 /* Ready */)
callback(...args);
state += 1;
}
if (callType === TRAILING)
callback(...args);
setTimeout(() => scheduled(RESET), 0);
scheduled(args);
};
const scheduled = schedule(onTrail, wait);
const func = (...args) => {
if (firstCall)
callback(...args);
scheduled(firstCall ? LEADING : TRAILING, args);
firstCall = false;
};
const clear = () => {
firstCall = true;
state = 0 /* Ready */;
scheduled.clear();

@@ -139,3 +137,3 @@ };

onCleanup(clear);
return Object.assign(func, { clear });
return Object.assign(fn, { clear });
}

@@ -142,0 +140,0 @@ function createScheduled(schedule) {

{
"name": "@solid-primitives/scheduled",
"version": "1.4.0",
"version": "1.4.1",
"description": "Primitives for creating scheduled — throttled or debounced — callbacks.",

@@ -57,4 +57,4 @@ "contributors": [

"devDependencies": {
"solid-js": "1.7.6",
"@solid-primitives/event-listener": "^2.2.13",
"solid-js": "1.7.9",
"@solid-primitives/event-listener": "^2.2.14",
"@solid-primitives/timer": "^1.3.7"

@@ -61,0 +61,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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