Socket
Socket
Sign inDemoInstall

@tamagui/use-debounce

Package Overview
Dependencies
Maintainers
0
Versions
1110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tamagui/use-debounce - npm Package Compare versions

Comparing version 1.107.0 to 1.108.0-1722728147390

24

dist/cjs/index.js

@@ -0,5 +1,6 @@

var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {

@@ -14,3 +15,10 @@ for (var name in all)

};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
mod
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var src_exports = {};

@@ -23,3 +31,3 @@ __export(src_exports, {

module.exports = __toCommonJS(src_exports);
var import_react = require("react");
var React = __toESM(require("react"));
function debounce(func, wait, leading) {

@@ -40,10 +48,10 @@ let timeout, isCancelled = !1;

function useDebounce(fn, wait, options = defaultOpts, mountArgs = [fn]) {
const dbEffect = (0, import_react.useRef)(null);
return (0, import_react.useEffect)(() => () => {
const dbEffect = React.useRef(null);
return React.useEffect(() => () => {
dbEffect.current?.cancel();
}, []), (0, import_react.useMemo)(() => (dbEffect.current = debounce(fn, wait, options.leading), dbEffect.current), [options.leading, ...mountArgs]);
}, []), React.useMemo(() => (dbEffect.current = debounce(fn, wait, options.leading), dbEffect.current), [options.leading, ...mountArgs]);
}
function useDebounceValue(val, amt = 0) {
const [state, setState] = (0, import_react.useState)(val);
return (0, import_react.useEffect)(() => {
const [state, setState] = React.useState(val);
return React.useEffect(() => {
const tm = setTimeout(() => {

@@ -50,0 +58,0 @@ setState((prev) => prev === val ? prev : val);

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {

@@ -15,3 +16,10 @@ for (var name in all)

};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
mod
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var src_exports = {};

@@ -24,3 +32,3 @@ __export(src_exports, {

module.exports = __toCommonJS(src_exports);
var import_react = require("react");
var React = __toESM(require("react"));
function _array_like_to_array(arr, len) {

@@ -99,4 +107,4 @@ (len == null || len > arr.length) && (len = arr.length);

fn
], dbEffect = (0, import_react.useRef)(null);
return (0, import_react.useEffect)(function() {
], dbEffect = React.useRef(null);
return React.useEffect(function() {
return function() {

@@ -106,3 +114,3 @@ var _dbEffect_current;

};
}, []), (0, import_react.useMemo)(function() {
}, []), React.useMemo(function() {
return dbEffect.current = debounce(fn, wait, options.leading), dbEffect.current;

@@ -114,4 +122,4 @@ }, [

function useDebounceValue(val) {
var amt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, _useState = _sliced_to_array((0, import_react.useState)(val), 2), state = _useState[0], setState = _useState[1];
return (0, import_react.useEffect)(function() {
var amt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, _React_useState = _sliced_to_array(React.useState(val), 2), state = _React_useState[0], setState = _React_useState[1];
return React.useEffect(function() {
var tm = setTimeout(function() {

@@ -118,0 +126,0 @@ setState(function(prev) {

@@ -1,2 +0,2 @@

import { useEffect, useMemo, useRef, useState } from "react";
import * as React from "react";
function debounce(func, wait, leading) {

@@ -17,10 +17,10 @@ let timeout, isCancelled = !1;

function useDebounce(fn, wait, options = defaultOpts, mountArgs = [fn]) {
const dbEffect = useRef(null);
return useEffect(() => () => {
const dbEffect = React.useRef(null);
return React.useEffect(() => () => {
dbEffect.current?.cancel();
}, []), useMemo(() => (dbEffect.current = debounce(fn, wait, options.leading), dbEffect.current), [options.leading, ...mountArgs]);
}, []), React.useMemo(() => (dbEffect.current = debounce(fn, wait, options.leading), dbEffect.current), [options.leading, ...mountArgs]);
}
function useDebounceValue(val, amt = 0) {
const [state, setState] = useState(val);
return useEffect(() => {
const [state, setState] = React.useState(val);
return React.useEffect(() => {
const tm = setTimeout(() => {

@@ -27,0 +27,0 @@ setState((prev) => prev === val ? prev : val);

@@ -1,2 +0,2 @@

import { useEffect, useMemo, useRef, useState } from "react";
import * as React from "react";
function _array_like_to_array(arr, len) {

@@ -75,4 +75,4 @@ (len == null || len > arr.length) && (len = arr.length);

fn
], dbEffect = useRef(null);
return useEffect(function() {
], dbEffect = React.useRef(null);
return React.useEffect(function() {
return function() {

@@ -82,3 +82,3 @@ var _dbEffect_current;

};
}, []), useMemo(function() {
}, []), React.useMemo(function() {
return dbEffect.current = debounce(fn, wait, options.leading), dbEffect.current;

@@ -90,4 +90,4 @@ }, [

function useDebounceValue(val) {
var amt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, _useState = _sliced_to_array(useState(val), 2), state = _useState[0], setState = _useState[1];
return useEffect(function() {
var amt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, _React_useState = _sliced_to_array(React.useState(val), 2), state = _React_useState[0], setState = _React_useState[1];
return React.useEffect(function() {
var tm = setTimeout(function() {

@@ -94,0 +94,0 @@ setState(function(prev) {

{
"name": "@tamagui/use-debounce",
"version": "1.107.0",
"version": "1.108.0-1722728147390",
"types": "./types/index.d.ts",

@@ -30,3 +30,3 @@ "main": "dist/cjs",

"devDependencies": {
"@tamagui/build": "1.107.0",
"@tamagui/build": "1.108.0-1722728147390",
"react": "^18.2.0 || ^19.0.0"

@@ -33,0 +33,0 @@ },

@@ -1,2 +0,2 @@

import { useEffect, useMemo, useRef, useState } from 'react'
import * as React from 'react'

@@ -53,5 +53,5 @@ type DebounceSettings = {

): DebouncedFn {
const dbEffect = useRef<DebouncedFn | null>(null)
const dbEffect = React.useRef<DebouncedFn | null>(null)
useEffect(() => {
React.useEffect(() => {
return () => {

@@ -62,3 +62,3 @@ dbEffect.current?.cancel()

return useMemo(() => {
return React.useMemo(() => {
dbEffect.current = debounce(fn, wait, options.leading) as unknown as DebouncedFn

@@ -74,5 +74,5 @@ return dbEffect.current

export function useDebounceValue<A>(val: A, amt = 0): A {
const [state, setState] = useState(val)
const [state, setState] = React.useState(val)
useEffect(() => {
React.useEffect(() => {
const tm = setTimeout(() => {

@@ -79,0 +79,0 @@ setState((prev) => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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